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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Javascript not working in IE

    My Body looks like this:
    Code:
    <body>
    <div class="postprofile" id="profile1">
            <span style="white-space:nowrap;">
                       <span style="color:#536482;">Posts</span>: </span> 5
       <br />
    </div>
    </body>
    I want to get the number 5 so I use this javascript:
    Code:
    x = document.getElementsByTagName('div')
    For(y=0;y<x.length;y++)
    {
    If(x[y].className == "postprofile"){
    A= x[y].innerHTML;
    B=parseInt(x[y].innerHTML.split("Posts</span>: </span> ")[1]);
    Document.write(B);
                                                       }
    }
    And it worked fine in Firefox, but not in IE. Can anybody help me with this??

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    168
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Apart from the obvious case errors ( 'Document' instead of 'document', 'For' instead of 'for') try alerting A :

    alert(A);

    You will see that browsers interpret your HTML differently so you need to check your match is going to be universal or create a specific node for the numeric value.
    Last edited by Puffin the Erb; 01-10-2010 at 04:16 PM.


  •  

    Posting Permissions

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