[Javascript] innerHTML

Lau lau at goldenweb.com.au
Thu Aug 23 09:53:30 CDT 2001


With NN4 you have to use layers instead of innerHTML ... which means that your object has to be
absolutely positioned... no such restrictions with IE or NN6. Here's some cross-browser code that
will do it for you.

<html><head>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
function WriteInnerHTML(p_DivID,p_htmlstr){
 if (document.getElementById) {
       document.getElementById(p_DivID).innerHTML= p_htmlstr;
 } else {
     with (document.layers[p_DivID].document) {
     open();
     write(p_htmlstr);
     close();
     }
 }
}
// -->
</SCRIPT>
</head><body>
<DIV ID=Div1 STYLE="position: absolute; left: 100px; top: 100px;"></DIV>
<DIV ID=Div2></DIV>
<INPUT TYPE=BUTTON ONCLICK='Javascript:WriteInnerHTML("Div1","<P>Put this text<BR>in Absolute
positioned DIV1</P>");'>
<INPUT TYPE=BUTTON ONCLICK='Javascript:WriteInnerHTML("Div2","<P>Put this text<BR>in non-positioned
DIV2</P>");'>
</body></html>


Enjoy,
Lau  :-)





----- Original Message -----
From: Cutter Bl
To: javascript at LaTech.edu
Sent: Thursday, August 23, 2001 10:35 PM
Subject: Re: [Javascript] innerHTML


innerHTML is a property first accessable within IE5, so if you need backwards compatability it might
not be the route to go. I'm not sure how well it's supported by NN. NN6 might handle it, I've heard
it can be extremely buggy in NN4.x. A nice source of information can be found on the Microsoft site.
There is also a stellar example explanation on fellow lister Peter-Paul Koch's site.

Cutter
Falcon Knives
----Original Message Follows----
From: hormuz maloo
Reply-To: javascript at LaTech.edu
To: "'javascript at LaTech.edu'"
Subject: [Javascript] innerHTML
Date: Thu, 23 Aug 2001 10:11:28 +0530


Can somebody please elaborate a little on "innerHTML". I have heard it
mentioned at various places. What does it do exactly? Is it part of
JavaScript, CSS, or what? Will appreciate a short summary or some good links
on the topic.
Thanks in advance,
Hormuz

Date: Mon, 20 Aug 2001 08:44:36 -0700
Subject: Re: [Javascript] getting text from another page
From: Ben Curtis
To:
Reply-To: javascript at LaTech.edu


> I need to grab some text from one HTML page and put it on another.
>
> The text conveniently sits inbetween some tags called
>
> How do I go about getting this text on another html page?


>I would suggest going server-side with this; PHP, Perl, ASP, or ColdFusion
>would do nicely. If, for some reason, you *need* to do this clientside,
then
>you will need to make sure the two pages are in the same domain. With IE or
>N6 you can then get the innerHTML of the page, and use a regular expression
>to find the relevant string. Could be a lot of work or piece of cake. Good
>luck.

>--
>+Ben Curtis

>"One of the symptoms of an approaching nervous breakdown
>is the belief that one's work is terribly important."
>- Bertrand Russell (1872-1970)




Get your FREE download of MSN Explorer at http://explorer.msn.com
_______________________________________________ Javascript mailing list Javascript at LaTech.edu
http://www.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list