Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling document.write???? 2

Status
Not open for further replies.

MikeDee

Programmer
Aug 2, 2001
19
GB
Can somebody help me????

The problem I have here in this program is that when you click on 'ISG' it document.write("ISG Content"); into a new page.

What it suppose to do is document.write("ISG Content");
underneath the 'm_isg.gif' image?

The program below....
-----------------


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>

<script language=&quot;javascript&quot;>
function isg_content()
{
document.write(&quot;isg content&quot;);
}

</script>

</head>

<body bgcolor=&quot;#FFFFFF&quot;>
<table width=&quot;75&quot; border=&quot;0&quot; cellspacing=&quot;6&quot; cellpadding=&quot;0&quot;>
<tr>
<td><img src=&quot;m_head.gif&quot; width=&quot;130&quot; height=&quot;38&quot;><BR>
<img onclick=&quot;javascript: isg_content();&quot; src=&quot;m_isg.gif&quot; width=&quot;130&quot; height=&quot;22&quot;><BR>
<img src=&quot;m_svg.gif&quot; width=&quot;130&quot; height=&quot;22&quot;><BR>
<img src=&quot;m_TDC.gif&quot; width=&quot;130&quot; height=&quot;22&quot;><BR>
<img src=&quot;m_pab.gif&quot; width=&quot;130&quot; height=&quot;22&quot;><BR>
<img src=&quot;m_bot.gif&quot; width=&quot;130&quot; height=&quot;16&quot;></td>
</tr>
</table>

</body>
</html>
 
document.write clears the page before it writes. You either need to use it when the page loads (not really viable option for you) or use a <span> (or a <div> I think) and give it a name, then use the innerHTML property to change what's in the span.

Code:
<span name=&quot;span1&quot;>  </span>

<script>
span1.innerHTML = &quot;Some text&quot;;
</script>

You get the idea.

Iain
 
Well the innerHTML is a prepritory extension -- and only works in Netscape 6.x + and IE 4+.

I would use the DOM standard to insert the content by creating a text node --

textnode = document.createTextNode(&quot;some text&quot;);
document.getElementById(&quot;span1&quot;).appendChild(textnode);
===
Supports Mozilla and Web Standards
Knows HTML/XHTML, CSS1, JavaScript, PHP, C++, DOM1
===
 
yeah, but DOM wont work in ie4x & nn4x, i guess.. :-( Victor
 
is there somewhere to get a simple free example?
 
shmmeee gave u workin example
<span id=daOne style=&quot;position:absolute&quot;></span>-relative if u want 2 put it into the table

ie4x:
if (document.all)
document.all.daOne.innerHTML='new content'
ie5x, nn6:
if (document.getElementById) document.getElementById(&quot;daOne&quot;).innerHTML='new content'
or use DOM like Trevman suggested
nn4x:
if(document.layers){
with (document.layers.daOne.document){
open()
write('new content')
close()
}
}
Victor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top