Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > FAQ Topic - How do I modify the current page in a browser?

Reply
Thread Tools

FAQ Topic - How do I modify the current page in a browser?

 
 
FAQ server
Guest
Posts: n/a
 
      12-22-2006
-----------------------------------------------------------------------
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.getElementById("anID").innerHTML=
"Some <em>new</em> Content";
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</em> Content")
With the below code also in the page:

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")
}

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.javascript FAQ is at http://www.jibbering.com/faq/.
The FAQ workers are a group of volunteers.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ Topic - How do I modify the current page in a browser? FAQ server Javascript 0 06-22-2007 11:00 PM
FAQ Topic - How do I modify the current page in a browser? FAQ server Javascript 0 04-22-2007 11:00 PM
FAQ Topic - How do I modify the current page in a browser? FAQ server Javascript 2 02-21-2007 03:03 PM
FAQ Topic - How do I modify the current page in a browser? FAQ server Javascript 0 10-24-2006 11:00 PM
FAQ Topic - How do I modify the current page in a browser? FAQ server Javascript 1 08-27-2006 11:37 PM



Advertisments