1 | 2 | 3 | 4

11 - 15   [17]

Call Prototype for IE Legacy

Relates to DOM Scripting and Exploder

One cautionary note I discovered when testing access to overriden methods is that IE5.01 does not recognize the call method. I had only recently started using this to inherit public access properties and methods from the constructor's prototype, mainly for asthetic reasons (and one less line of code). Well the IE fix, as performed previously with prototyping Array objects, is a new method for the Function object's prototype as follows:

if (typeof Function.prototype.call == "undefined") {
  Function.prototype.call = function(obj, param) {
    obj.base = this;

This simply acts as a wrapper for the traditional method of prototype inheritance, by calling the constructor function of the prototype, and fortunately is compatible with IE5.01.

Posted on Oct 08, 2004 at 04:47:21. [Comments for Call Prototype for IE Legacy- 0]

Super Simulation in Javascript OOP

Relates to DOM Scripting

Writing some Javascript the other day I found myself wanting to override a method of an object's prototypical object while still having access to the inherited method. That is, in class based terminology, I wanted to be able to invoke the overriden method of the superclass. In Java this is achieved with the keyword super which provides a reference to the current object as an instance of its superclass. However, as a prototype-based language, Javascript does not provide such a reference. Kevin Lindsey demonstrates the recursive dilemma and suggests an idiom for simulating constructor chaining by utilising the ECMA compliant call method. While this could serve my purpose, I decided to look for a way to create a single reference to access overriden member variables and methods (just like super).

Here is one possible solution:

Object.prototype.parent = function(type) {
  var p = new Object();
  for (x in type.prototype) {
    if (x != "parent") {
      p[x.toString()] = this[x.toString()];          
  return p;  

function BoxContainer(param) {
  Container.call(this, param);
  var parent = this.parent(BoxContainer);
  this.service = function() {
    if (this.service.arguments.length == 0) {    
      return parent.service();    
    else {
      // .. do some stuff ..
      return stuff;  
BoxContainer.prototype = new Container;

The prototype object, Container, is that used by Douglas Crockford in his article Private Members in Javascript.

A new method, parent, is added to the prototype property of the Object object. This method allows an temporary object to be filled with the public access variables and methods of a prototype before they are overriden. So, the constructor function, BoxContainer, invokes this method passing its prototypical object. The method returns a new object reference filled with all the properties and methods of the prototypical object, and this is assigned to a private variable, parent. Then a closure allows the inner function service to maintain access to parent after the constructor function BoxContainer has returned. (NB while super may have been an elegant choice for the identifier, it is a reserved word, so I choose to use parent - not to be confused with DOM!)

Posted on Oct 08, 2004 at 04:44:50. [Comments for Super Simulation in Javascript OOP- 6]

Moving Up the SERPs

Relates to SEO and Blogging

Following the latest Google PR update, I have moved into the top 15 on Google for my name! Quite stoked when I think back to 6 months ago and I was lost somewhere in the depths of the three million or so Google SERP's for Tom Wright!

Posted on Oct 08, 2004 at 04:41:10. [Comments for Moving Up the SERPs- 0]

Web Based Applications

Relates to PHP and Accessibility, DOM Scripting

Over on WASP Chris Kaminski talks about the future of the web as a platform for developing and deploying applications. In the wake of Javascript's XmlHttpRequest this has become a very popular topic for discussion. The ability to call data from the server via client-side scripting without the need to reload the whole page is an exciting prospect and already some excellent utilities are emerging. Bitflux led the way with Live Search which is under further development over at Colly Logic. Meanwhile, Harry Fuecks, in follow up to his Crouching Javascript, Hidden PHP series, has established the SourceForge project ScriptServer - a complete set of tools for connecting PHP and Javascript together. Although proprietary in detail, Jonathan Zufi applies the M$ implementation of XmlHttpRequest to form validation with VBScript and ASP. On a much grander scale, Gmail and A9 both offer fine examples of web based applications powered by considerable Javascript.

Personally, I am excited by the new opportunities provided by a web based platform and it is nice to see client side scripting appearing in the spotlight again. The communication between client-side and server-side scripts is providing plenty of potential for increased usability and enhanced UI. However, there is one critical concern with any application that puts major emphasis on client side scripting - accessibility. Fortunately A9 still functions with scripts disabled, however GMail currently displays that gratuitous javascript is required message! Done right the enhancements provided by XmlHttpRequest and other DHTML tools can improve the usability of an application without reducing its accessibility. But a dependance on scripting could see a drastic demise to former times and a blank screen served upto 20% of the web!

Posted on Oct 03, 2004 at 02:48:18. [Comments for Web Based Applications- 0]

HAVING Clause in MySQL

Relates to MySQL and Databases

Point of note that an aggregate function is meaningless in the WHERE clause of an SQL statement. Common sense really considering the return from the function cannot be calculated until the rows have been returned. I discovered this on trying to retrieve a set of distinct categories based on the existence of at least one visible record classified in that category. The solution uses the HAVING clause.

SELECT lookup.category
FROM data LEFT JOIN lookup
ON data.cid = lookup.cid 
WHERE data.visible = 1 
GROUP BY lookup.cid 
HAVING count(data.id) > 0 

Posted on Oct 03, 2004 at 02:47:27. [Comments for HAVING Clause in MySQL- 0]

Breadcrumbs Trail

[ Home ] -> TW Blog -> Archives for October 2004
Site Map

The Severn Solutions website achieves the following standards:

[ XHTML 1.0 ] [ CSS 2 ] [ WAI AA ] [ Bobby AA ]

Page compiled in 0.008 seconds