Hi all,
I came across some code on a big-name site, that I dont like, but need
to support (I am writing a DOM model for a product).
Here is the code:
var d=document.writ eln;
d("<HTMLSTUFF>. ....");
Now, this works in IE, but does not work in Netscape. Netscape will
throw an exception. The authors only did this in IE (using browser
detection), but it is just plain bad, in my opinion.
The variable d is a function object. It is not necesarially associated
with document. In fact, in the Mozilla implementaiton of javascript,
this object would be executed from the global (window) object.
My question, is: "Is this a common thing to do?" Do people do this
often? In what other contexts do they do this?
I am in no way advocating this type of code... nor do I plan to use it.
I need to support it, which is whay I ask.
Just so anyone is curious, a MUCH better solution would be:
function d(text) { document.writel n(text) }
d("<HTMLSTUFF>. ....");
Ok, Thanks,
Brian
I came across some code on a big-name site, that I dont like, but need
to support (I am writing a DOM model for a product).
Here is the code:
var d=document.writ eln;
d("<HTMLSTUFF>. ....");
Now, this works in IE, but does not work in Netscape. Netscape will
throw an exception. The authors only did this in IE (using browser
detection), but it is just plain bad, in my opinion.
The variable d is a function object. It is not necesarially associated
with document. In fact, in the Mozilla implementaiton of javascript,
this object would be executed from the global (window) object.
My question, is: "Is this a common thing to do?" Do people do this
often? In what other contexts do they do this?
I am in no way advocating this type of code... nor do I plan to use it.
I need to support it, which is whay I ask.
Just so anyone is curious, a MUCH better solution would be:
function d(text) { document.writel n(text) }
d("<HTMLSTUFF>. ....");
Ok, Thanks,
Brian
Comment