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!

Netscape/Mozilla - Writing to a <div> tag

Status
Not open for further replies.

NJDrew

Technical User
Dec 21, 2001
31
US
Yes, sorry this is a cross browser compatibility issue. I have a loop that is writing to a DIV tag in a table. In IE, this works fine, but in Mozilla and Netscape I get "thumbscroll is undefinied" (thumbscroll being the div tag) error. The loops are being called (and passed values) by a flash file embeded in the page. I cut and pasted the essentials below. Thank you in advance for any suggestions.

Drew

Code:
<html>
<head>
<script language="JavaScript">
<!-- 
function event(s, u, i) 
{
	b=1;
	var ThumbCodeLines = "";
while(i<=s)
  {
	ThumbCodeLines += "<a href='#' OnMouseOver='newMap("+i+")'><IMG SRC='"+u+i+"t.JPG'></img></a>";
	thumbscroll.innerHTML = ThumbCodeLines;
	i++;
	b++;
  }
}

function newMap(y, p) {
if (y < 5000)
{
document.de.src= o+y+".JPG";
}
else
{
o = p;
}
}
-->
</script>
</head>

<body>
<img name=de  src="images/SampleDrift.jpg" align="center" vspace=10>
<table border=0>
<div id='row'>
<div id='thumbscroll'>
<center><font color=#494C4E>.</font></center>
</div>
</div>
</table>
</body>
</html>

&quot;Mistakes are the portals of discovery&quot;
James Joyce
 

Try changing this:

Code:
<div id='row'>
<div id='thumbscroll'>

to this:

Code:
<div id="row">
<div id="thumbscroll">

I'm not sure if single quotes are allowed as delimiter characters for HTML or not... Some browsers might be more forgiving than others.

Then, change this:

Code:
thumbscroll.innerHTML

to this:

Code:
document.getElementById('thumbscroll').innerHTML

Which is the correct way of referring to the DIV.

Hope this helps,
Dan
 
Dan, thank you for the suggestions, however
Code:
document.getElementById('thumbscroll').innerHTML

dosn't seem to want to work in Netscape/Mozilla or IE. It dosn't throw back any errors, but it dosn't write to Thumbscroll either?

&quot;Mistakes are the portals of discovery&quot;
James Joyce
 
Code:
<html>
<head>
<script language="JavaScript">
<!-- 
function event(s, u, i) 
{

    var ThumbCodeLines = "";
	while(i<=s)
  {
    ThumbCodeLines += "<a href='#' OnMouseOver='newMap("+i+")'><IMG SRC='"+u+i+"t.JPG'></img></a>";
    document.getElementById('thumbscroll').innerHTML
	//thumbscroll.innerHTML = ThumbCodeLines;
    i++;
  }
}

function newMap(y, p) {
if (y < 5000)
{
document.de.src= o+y+".JPG";
}
else
{
o = p;
}
}
-->
</script>
</head>
<body>

<img name=de  src="images/SampleDrift.jpg" align="center" vspace=10>
<table border=0>
<div id="row">
<div id="thumbscroll">
<center><font color=#494C4E>.</font></center>
</div>
</div>
</table>

</body>
</html>

&quot;Mistakes are the portals of discovery&quot;
James Joyce
 
UhhOhh,

Not much of a "fix" there:
How about:

<table border="0" width="100%">
<tr><td>
<div id="row">
<div id="thumbscroll">
<center><font color=#494C4E>.</font></center>
</div>
</div>
</td></tr>
</table>
 
Lrnmore, the table structure wasn't the problem, but I did fix it anyway. Thanks

Dan,

Sorry, I relized that when I implemented your code, I wasn't assigning anything to it. This works.

Code:
document.getElementById('thumbscroll').innerHTML = ThumbCodeLines;

Sorry about that, thank you for your help.

&quot;Mistakes are the portals of discovery&quot;
James Joyce
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top