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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

span1 not defined in netscape and mozilla

Status
Not open for further replies.

jvdboom

Programmer
Aug 18, 2002
93
BE
There is a line in the .js that says:
span1.innerHTML = uit;
However it seems that span1 doesn't change (it does in IE)
and it even gives the error span1 not defined. If you click the next link on the menu-frame it will load instead of the frames(like _parent)
Is this something about runnig the script before span1 is seen?
here the html:
<html><head>
<title>Nieuws</title>
<style>
BODY{
scrollbar-3dlight-color:#DAD7DA;
scrollbar-arrow-color:#0000f6;
scrollbar-dark-shadow-color:#000000;
scrollbar-face-color:#E8E4E8;
scrollbar-shadow-color:#EAE5EA;
scrollbar-track-color:#F4EFF4;
scrollbar-highlight-color:#FEF9FE;
}
</style>
</head><body bgcolor=#EFEAEF><span id=&quot;span1&quot;>Bezig met laden, even geduld...</span><script src=&quot;xmlnieuws1.js&quot;></script>
</body></html>


Thanks for your help
 
First of all the code is missing from the page.

If you want to reference objects like span1 and this reference is not in a function then you should make sure that the object is made before the reference (see example below)
will not work:
<script>
alert(document.getElementById('txtObject'))
</script>
<input type=text id='txtObject'>
will work:
<input type=text id='txtObject'>
<script>
alert(document.getElementById('txtObject'))
</script>

Instead of referencing the span1 you can try the full path to the object (biginning with document like document.form1.text1). Or you can try document.getElementById but this is not supported by older browsers (I don't care about that and allways use getElementById or getElementsByName)
 
thabks ,but I have still a few problems in trhe script the
.text works in IE but not in NS (noden.text)and some onther things maybe

this is the .JS :
//alert('test');

var uit;var titel;var achtergkleur;var tekstkleur;var hoofdtitel;var docnaam;var standaardpag;var dezepagina;var url;var label;var URLindex;var loopindex;//declaratie
titel = &quot;Nieuws&quot;;
achtergkleur=&quot;#EFEAEF&quot;;
tekstkleur=&quot;#333333&quot;;
hoofdtitel=&quot;Nieuws&quot;;
standaardpag=&quot;reeks1.xml&quot;;//standaard ingestelde pagina(default)
dezepagina=&quot;nieuws2.htm&quot;;
//einde aanpassingsgebied
//wijzig niets vanaf hier

if (location.search.substring(1).indexOf('.xml')!=-1){docnaam=location.search.substring(1)} else {docnaam=standaardpag}
//alert(docnaam);
//uit = &quot;<html><head><title>&quot; + titel + &quot;</title><meta http-equiv='Content-Type content=text/html; charset=iso-8859-1'></head><body bgcolor=&quot; + achtergkleur + &quot; text=&quot; + tekstkleur + &quot;><div align=center><h1>&quot; + hoofdtitel + &quot;</h1></div><br>&quot;;
uit =&quot;<span id=f2></span>&quot;;
importXML();
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument(&quot;&quot;, &quot;&quot;, null);
xmlDoc.onload = Startloading;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;);
xmlDoc.onreadystatechange = tmp;
}
else
{
alert('Sorry, Uw browser kan dit script niet aan.');
return;
}
xmlDoc.load(docnaam);
}

function tmp()
{
if (xmlDoc.readyState == 4) Startloading();
}

function opmaak(noden)
{

var nodenaam = noden.nodeName;
var nodeinh = noden.text;
//alert(noden.nodeName);
//alert(noden.text);
var huit = &quot;&quot;;
var reuit;
switch(nodenaam)
{

case &quot;pic&quot;:
huit = &quot;<img src=\&quot;&quot; + nodeinh + &quot;\&quot;>&quot;;
break;
case &quot;onder&quot;:
huit = &quot;<u>&quot; + nodeinh + &quot;</u>&quot;;
break;
case &quot;vet&quot;:
huit = &quot;<b>&quot; + nodeinh + &quot;</b>&quot;;
break;
case &quot;cursief&quot;:
huit = &quot;<i>&quot; + nodeinh + &quot;</i>&quot;;
break;
case &quot;br&quot;:
huit = &quot;<br>&quot;;
break;
case &quot;link&quot;:
var nodeurlcount=noden.childNodes.length;
url=null;label=null;

for(URLindex=0;URLindex<nodeurlcount;URLindex++)
{
switch(noden.childNodes.item(URLindex).nodeName)
{
case &quot;durl&quot;:
url = dezepagina + &quot;?&quot; + noden.childNodes.item(URLindex).text;
break;

case &quot;url&quot; :
url = noden.childNodes.item(URLindex).text;
break;
case &quot;label&quot;:
label = noden.childNodes.item(URLindex).text;
break;
default:
reuit = opmaak(noden.childNodes.item(URLindex));
break;
}

}
if (label==null){label=url}
if (reuit!=null){label=reuit}
if (url==null){huit = &quot;fout&quot;} else {huit = huit + &quot;<a href=\&quot;&quot; + url + &quot;\&quot; target=\&quot;_self\&quot;>&quot; + label + &quot;</a>&quot;}
break;
}
return(huit);
}

function Startloading()
{
var RootElement1;
var loopindex;
var vraag;

vraag=0;
var antwoord;
var CurrentNode;

RootElement1=xmlDoc.documentElement;
if(RootElement1==null)
{
uit = uit + &quot;<font color=red><b>De gegevens van het XML bestand kan niet worden opgehaald</b></font>&quot;;
}
else
{
var nodecount=RootElement1.childNodes.length;
// uit = uit + RootElement1.nodeName;
//uit = uit + location.search.substring(1)
switch(RootElement1.nodeName)
{
case &quot;quiz&quot;:
uit = uit + &quot;<p align=left><form name=quiz1 method=POST action=/cgi-bin/quiz.cgi>&quot;;
break;
}

for(loopindex=0;loopindex<nodecount;loopindex++)
{

CurrentNode=RootElement1.childNodes.item(loopindex);
switch(RootElement1.nodeName)
{
case &quot;quiz&quot;:

switch(CurrentNode.nodeName)
{
case &quot;vraag&quot;:
vraag++;
antwoord=0;
uit = uit + &quot;<b>Vraag &quot; + vraag + &quot; : &quot; + CurrentNode.text + &quot;</b><br>&quot;;
break;
case &quot;antwoord&quot;:

antwoord++;
uit = uit + &quot;<input type=radio name=vr&quot; + vraag + &quot; value=&quot; + antwoord + &quot;>Mogelijkheid &quot; + antwoord + &quot; : &quot; + CurrentNode.text + &quot;<br>&quot;;
break;

}
break;
case &quot;nieuws&quot;:
switch(CurrentNode.nodeName)
{
case &quot;titel&quot;:

uit = uit + &quot;<h3>&quot; + CurrentNode.text + &quot;</h3>&quot;;
break;
case &quot;inleiding&quot;:

uit = uit + &quot;<i>&quot; + CurrentNode.text + &quot;</i>&quot;;
break;
case &quot;middel&quot;:

uit = uit + CurrentNode.text;
break;
case &quot;slot&quot;:

uit = uit + &quot;<b>&quot; + CurrentNode.text + &quot;</b>&quot;;
break;
case &quot;br&quot;:
uit = uit + &quot;<br>&quot;;
break;

default:
uit = uit + opmaak(CurrentNode);
break;
}
break;
}


}
}
switch(RootElement1.nodeName)
{
case &quot;quiz&quot;:
uit = uit + &quot;<input type=hidden name=vr value=&quot; + vraag + &quot;><input type=hidden name=quiz value=quiz1><br><input type=submit value=Verzenden></form></p>&quot;;
break;
case &quot;nieuws&quot;:
uit = uit + &quot;<br><br><A href=\&quot;Naar de vorige pagina gaan\&quot; onclick=\&quot;history.go(-1);return false;\&quot;>Vorige</A><br><a href=\&quot;&quot; + dezepagina + &quot;?&quot; + standaardpag + &quot;\&quot; target=\&quot;_self\&quot;>Terug naar overzicht</a>&quot;;
break;
}

//uit = uit + &quot;</body></html>&quot;;
//alert(uit);
//var win1 = window.open('/nieuws/nieuws2.htm','_self');
//win1.document.write(uit);
//win1.document.close();
//xmlDoc.unload;
document.getElementById('span1').innerHTML = uit;
}
 
I am a bit pressed for time so I can't go through the code.
What object is node? Is it the span?

Anyway to see all properties, events and methods supported by a browser you can script a list like so:

<input type=text id=node><br>
<script>
var objHTMElement = document.getElementById('node')
for(obj in objHTMElement){
document.write(obj + &quot;<br>&quot;);
}
</script>


You may be able to use .innerHTML but I don't know what node is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top