By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

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

P: n/a
-----------------------------------------------------------------------
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://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://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers.

Feb 21 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
FAQ server said the following on 2/20/2007 7:00 PM:
-----------------------------------------------------------------------
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:
That sentence doesn't read very well. It is either badly worded or is
missing some punctuation.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 21 '07 #2

P: n/a
FAQ server scribed:
>-----------------------------------------------------------------------
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
I don't have any content between the tags, and my app seems to work fine. Is
there some reason I might want to include some content (&nbsp; comes to
mind)?
--
Ed Jay (remove 'M' to respond by email)
Feb 21 '07 #3

P: n/a
In comp.lang.javascript message <v3tnt295t723jqpqeueufgnntva2mfll13@4ax.
com>, Tue, 20 Feb 2007 23:30:30, Ed Jay <ed***@aes-intl.composted:
>FAQ server scribed:
>>-----------------------------------------------------------------------
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›

I don't have any content between the tags, and my app seems to work fine. Is
there some reason I might want to include some content (&nbsp; comes to
mind)?
I have a page that uses javascript to fill DIVs or SPANs.

The first of such is, roughly <span>NO GOOD</span>, content immediately
replaced on page load using javascript by "ALL OK" or suchlike. Those
without script are duly warned that they are missing something. The
page is useful without script but more useful with it; there's no other
means available to substitute for script.

Then, while developing a page, it might be useful to see where the SPAN
actually is without actually writing to it. So write <span ID=Jim>Jim
is here!</spanand remember to clean it out before publication.

One can, of course, put SPAN content in the HTML and replace it by ""
with javascript later.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 21 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.