gregs

helping me remember what I figure out

IE , the dom and long numbers

| 2 Comments

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:

JavaScript:
  1. 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:

CODE:
  1. javascript:alert(document.all.myfield.value); void(0)

And to see what IE had actually written to the page:

CODE:
  1. javascript:alert(document.all.myfield.innerHTML ); void(0)

2 Comments

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

  2. Thanks John I’ll be sure to check this out.

Leave a Reply

Required fields are marked *.

*