IE , the dom and long numbers
by gregs on Apr.27, 2007, under JavaScript
I just spent the best part of 45 minutes trying to figure out a weird issue with a value I was pulling out of a select box (using $F(element)). The value in question was a long number: 1000002229651626, which IE converted at the time of writing the value to the page (this was an AJAX call) to: 1.00000222965163e+15.
IE decided to convert my number when I was using the new Option() method to populate the drop down, making the debug process even harder. I personally can't wait until we get a firebug like extension for IE, right now I'd just settle for an option to view the rendered source.
Rant over, the solution is to convert the number to a string:
-
selectBox[x] = new Option('Some text',new String(1000002229651626),false);
On the plus side I came across a neat way to debug values in a form field using the address the browser address bar:
-
javascript:alert(document.all.myfield.value); void(0)
And to see what IE had actually written to the page:
-
javascript:alert(document.all.myfield.innerHTML ); void(0)
July 20th, 2007 on 8:22 am
You should check out the “IE Developer Toolbar.” It has many of the things you wish IE had.
http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en
Given this code…
Untitled
Testing
h1Test.style.color = “red”;
h1Test.innerHTML = “Post Test”;
I can view “Element Source” for “h1Test” and see this code…
Post Test
Pretty sweet!
July 25th, 2007 on 9:37 am
Thanks John I’ll be sure to check this out.