Simulating IE4+ Syntax in NN6

We can simulate different properties which are not supported by NN6 and are supported by IE. In other words we can create new properties which are not supported by NN6 for any type of object. For example "all", "innerText" and "outerHTML" are not supported by NN6. We can simulate them.

Simulating "all": (for example "document.all")
the Node static object is the object from which all elements are derived. That object’s prototype is enhanced here because you have to make sure that all nodes, especially the document node, can acquire the all property.
Here is the code:

if (!document.all)
{
Node.prototype.__defineGetter__(“all”, function()

{
if (document.getElementsByTagName(“*”).length)

{
switch (this.nodeType)

{
case 9:
return document.getElementsByTagName(“*”);
break;
case 1:
return this.getElementsByTagName(“*”);
break;
}
}
return ""
}

)
Node.prototype.__defineSetter__(“all”, function() {})
}



The anonymous function first establishes a branch in the code only for the object model if it supports the wildcard parameter for the document.getElementsByTagName() method. The function then performs slightly different extractions depending on whether the node is the document (type 9) or an element (type 1). If the all property should be queried for any other kind of node, the returned value is an empty string. Each time the all property is accessed, the
anonymous function executes to pick up all elements nested inside the current node. Therefore, the collection returned by the all property is always up to date, even if the node structure of the current object changes after the document loads.

Comments

Popular posts from this blog

Unable to delete Shared Services Provider in SharePoint (MOSS)

The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

Cannot add a SimpleContent column to a table containing element columns or nested relations