D
dhtml
Tried mailing the FAQ maintainer but the mail bounced.
The FAQ entry of topic:
http://www.jibbering.com/faq/#FAQ4_15
DocDom = (document.getElementById?true:false);
DocAll = (document.all?true:false);
DocStr=''
if (DocAll) DocStr="return document.all[id]"
if (DocDom) DocStr="return document.getElementById(id)"
GetRef=new Function("id", DocStr)
if (DocStr=='') { DynWrite=new Function("return false") } else {
DynWrite=new Function("id", "S", "GetRef(id).innerHTML=S; return
true")
}
Is a very poor quality example. Anyone reading that code who knows
what they are doing would probably consider the advice in the document
worthless.
It should be revised to not use the function constructor, for one. It
should definitely not declare variables without the var keyword. The
DocDom variable is also questionable. Does "DocDom" being true imply
something other than "document.getElementById" exists?
The explanation before the example is sufficient.
It would be a good idea to add something about script tag insertion.
This comes up fairly often.
========================================
SCRIPT tags inserted with innerHTML will not be evaluated in most
circumstances. Appending a
script tag will cause the script to be executed in most browsers.
The FAQ entry of topic:
http://www.jibbering.com/faq/#FAQ4_15
DocDom = (document.getElementById?true:false);
DocAll = (document.all?true:false);
DocStr=''
if (DocAll) DocStr="return document.all[id]"
if (DocDom) DocStr="return document.getElementById(id)"
GetRef=new Function("id", DocStr)
if (DocStr=='') { DynWrite=new Function("return false") } else {
DynWrite=new Function("id", "S", "GetRef(id).innerHTML=S; return
true")
}
Is a very poor quality example. Anyone reading that code who knows
what they are doing would probably consider the advice in the document
worthless.
It should be revised to not use the function constructor, for one. It
should definitely not declare variables without the var keyword. The
DocDom variable is also questionable. Does "DocDom" being true imply
something other than "document.getElementById" exists?
The explanation before the example is sufficient.
It would be a good idea to add something about script tag insertion.
This comes up fairly often.
========================================
SCRIPT tags inserted with innerHTML will not be evaluated in most
circumstances. Appending a
script tag will cause the script to be executed in most browsers.