...

View Full Version : span write for new Mozilla



Aiden
07-10-2002, 09:53 AM
Got this part of my script that pastes 2 a span, in this case the span is named "news". I can paste in all browsers except the Mozilla browser. Anybody know how to tack on a Mozilla check and write. I just couldn't work out how it references the span...


if (document.layers) {
document.layers.news.document.write(post)
document.layers.news.document.close()
} else if (document.all) {
news.innerHTML=post;
} else if (document.getElementById) {
document.getElementById("news").innerHTML=post;
} else {
return;
}

Thanx in @dvance.... :confused:

mordred
07-10-2002, 01:40 PM
Hmh, the code looks like being syntactically correct, and the referencing is done properly. Do you get any error messages in the JavaScript console (tools->web development->javascript console)?
Maybe posting the rest of the page (unless it's extremely big) sheds more light on this issue.

Bosko
07-10-2002, 03:27 PM
The problem is that you used the name="news" attribute,but for getElementById you need to use id="news".

Aiden
07-11-2002, 12:30 AM
sorry, yeah I didn't realise threads moved up list...

okay, so I know the problem isn't with the span paste part of this function.... it must be in how I'm checking the other frames form...

brief explanation: here is the function, it is kicked off onload. It checks a form named "cont" in another frame named "left". It looks at two fields in this form named "one" and "two". If the value of these fields is "clos" it pastes one thing to the span, otherwise it pastes another.

>>> can't make work in Mozilla 1.0 browser <<<

function loadit() {

if (top.left.document.cont.one.value=="clos") {
one = '<img src="images/yesone.gif">';
} else {
one = '<img src="images/noone.gif">';
}
if (top.left.document.cont.two.value=="clos") {
two = '<img src="images/yestwo.gif">';
} else {
two = '<img src="images/notwo.gif">';
}

gloat = foldone + foldtwo;

if (document.layers) {
document.layers.sitemap.document.write(gloat)
document.layers.sitemap.document.close()
} else if (document.all) {
sitemap.innerHTML=gloat;
} else if (document.getElementById) {
document.getElementById("sitemap").innerHTML=gloat;
} else {
return;
}
}
</script>
</head>
<body onload="loadit();">

<TABLE WIDTH="100" height="80">
<TR>
<TD nowrap style="padding: 5px;">
<SPAN ID="sitemap"></SPAN>
</TD>
</TR>
</TABLE>

Roy Sinclair
07-11-2002, 08:48 PM
You're putting the contents into fields names one and two but then turning around and trying to use fields named foldone and foldtwo.

Aiden
07-12-2002, 01:49 AM
yeah, sorry, just a mistake I made when I pasted/condensed the code for this forum...

the correct code (that doesn't work in Mozilla 1.0) is:


function loadit() {

if (top.left.document.cont.one.value=="clos") {
one = '<img src="images/yesone.gif">';
} else {
one = '<img src="images/noone.gif">';
}
if (top.left.document.cont.two.value=="clos") {
two = '<img src="images/yestwo.gif">';
} else {
two = '<img src="images/notwo.gif">';
}

gloat = one + two;

if (document.layers) {
document.layers.sitemap.document.write(gloat)
document.layers.sitemap.document.close()
} else if (document.all) {
sitemap.innerHTML=gloat;
} else if (document.getElementById) {
document.getElementById("sitemap").innerHTML=gloat;
} else {
return;
}
}
</script>
</head>
<body onload="loadit();">

<TABLE WIDTH="100" height="80">
<TR>
<TD nowrap style="padding: 5px;">
<SPAN ID="sitemap"></SPAN>
</TD>
</TR>
</TABLE>


VVVVVVVVVVVVVVVV

brief explanation: This function checks a form named "cont" in another frame named "left". It looks at two fields in this form named "one" and "two". If the value of these fields is "clos" it pastes one thing to the span, otherwise it pastes another.

DOESN"T WORK IN MOZILLA 1.0 - WORKS IN EVERYTHING ELSE

AAAAAAAAAAAAAAAA

Roy Sinclair
07-12-2002, 05:24 PM
The problem must lie in the code that checks the form values since I bypassed that code with some default values for one and two and it worked fine.

My first thought would be to try:

top.left.document.forms.cont.one.value

instead of

top.left.document.cont.one.value



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum