Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old August 27th, 2008, 12:05 AM
FAQ server
Guest
 
Posts: n/a
Default FAQ Topic - How do I modify the current page in a browser? (2008-08-27)

-----------------------------------------------------------------------
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</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.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://msdn2.microsoft.com/en-us/library/ms533897.aspx

http://developer.mozilla.org/en/docs...ment.innerHTML


--
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://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers. The sendings of these
daily posts are proficiently hosted by http://www.pair.com.




 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.