Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-10-2010, 07:06 AM   PM User | #1
huylord
New to the CF scene

 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
huylord is an unknown quantity at this point
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??
huylord is offline   Reply With Quote
Old 01-10-2010, 04:12 PM   PM User | #2
Puffin the Erb
Regular Coder

 
Join Date: Oct 2004
Posts: 168
Thanks: 0
Thanked 5 Times in 5 Posts
Puffin the Erb is an unknown quantity at this point
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..
Puffin the Erb is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:04 PM.


Advertisement
Log in to turn off these ads.