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 3 of 3
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    NN & IE differences

    I have 2 JavaScript functions; the first is, firstSlide(), which calls the second, findObject(obj). The functions behave as expected in IE, but NN is unhappy; the initial value of MyCaption, “Initial Caption” is not replaced with the contents of the variable “myTitle.”

    function firstSlide(){
    if(myTitle.length>0){
    findObject("MyCaption").innerHTML="<i>" + myTitle + "</i>";
    }
    }

    function findObject(obj){
    if(document.getElementById){
    alert("getElementById() returns "+document.getElementById(obj));
    return document.getElementById(obj);
    }
    else if (document.all){
    return document.all(obj);
    }
    }

    When I run this code in IE the alert in findObject() displays:
    getElementById() returns [object]
    whereas, in NN the alert displays:
    getElementById() returns null.

    The object, MyCaption, is, as you might expect, the caption for a table and is created in document body.

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <caption><span id="myCaption">Initial Caption</span></caption>
    <tr>...

    I’ve made numerous alterations in an attempt to make NN happy, but to no avail. I must be overlooking some basic flaw. Your assistance will be appreciated.

    Thanks, GrandpaB

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Javascript is case-sensitive.

    findObject("MyCaption").innerHTML="<i>" + myTitle + "</i>";
    ...
    <span id="myCaption">Initial Caption</span>

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    glenngv,

    Thanks, I've been developing for a while and know of JS's sensitivity to case, but I now need to develop for both IE and NN. When, on my first foray into NN it behaved differently than IE, I panicked. I forgot to check the basics.

    Thanks again, GrandpaB


  •  

    Posting Permissions

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