Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    span write for new Mozilla

    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....

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Netherlands
    Posts
    217
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The problem is that you used the name="news" attribute,but for getElementById you need to use id="news".

  • #4
    New Coder
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    where is the problem?

    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>

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're putting the contents into fields names one and two but then turning around and trying to use fields named foldone and foldtwo.

  • #6
    New Coder
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    just a typo!

    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

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •