-----------------------------------------------------------------------
FAQ Topic - How do I modify the current page in a browser?
-----------------------------------------------------------------------
Using the DOM the non-standard but widely implemented innerHTML
extension, the following would be sufficient to modify the content
of any element that can have content:
« <div id="anID">Some Content</div» with script of
« document.getEle mentById("anID" ).innerHTML=
"Some <em>new</emContent"; »
Where "anID" is the (unique on the HTML page) ID attribute value
of the element to modify.
The script below adds support for « document.all » capable browsers.
Support for NN4 is also possible, but certain issues mean that
it is not listed here. Using the example above, the call would
be written:
« DynWrite('anID' ,"Some <em>new</emContent") »
With the below code also in the page:
DocDom = (document.getEl ementById?true: false);
DocAll = (document.all?t rue:false);
DocStr=''
if (DocAll) DocStr="return document.all[id]"
if (DocDom) DocStr="return document.getEle mentById(id)"
GetRef=new Function("id", DocStr)
if (DocStr=='') { DynWrite=new Function("retur n false") } else {
DynWrite=new Function("id", "S", "GetRef(id).inn erHTML=S; return true")
}
An alternative DynWrite function:
http://www.jibbering.com/faq/faq_not..._dynwrite.html
http://msdn.microsoft.com/workshop/a.../innerHTML.asp
http://www.mozilla.org/docs/dom/domr...8.html#1018427
===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javas cript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers.