SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast Silverhawk's Avatar
    Join Date
    Sep 2003
    Location
    Malaysia
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript DOM Not working in IE?

    I'm trying to create an interface like gmail's attachments where fields are dynamically generated when needed. In my case, the fields are for e-mailing purposes.

    Here's a link to the test page.
    http://hawks-eyrie.net/js/test.html

    It works well in Firefox and Opera. However in IE when you click on it nothing happens. IE does not return an error which will help me debug what is going wrong.

    My guess is that it has something to do with how IE handles the onClick event. Though i am not quite sure. So I hope someone with the experience/knowledge in javascript can help me solve this.

    Thanks in advance.

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE doesn't like this:
    link.setAttribute("onClick", "addFields");

    You can use this instead:
    link.onclick = addFields;

  3. #3
    SitePoint Enthusiast Silverhawk's Avatar
    Join Date
    Sep 2003
    Location
    Malaysia
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now it works
    Thanks!

    Is there anything else I have to look out for when it comes to IE and javascript?

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I recall that IE 5 (not sure exact version) had some problems in general with setAttribute - it didn't like this for example:
    formInput.setAttribute("type", "checkbox");

    you had to use formInput.type = "checkbox";

    I think in ie6 + the only thing to watch for is event handlers, in that context.

  5. #5
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are sadly too many things to watch out for when dealing with IE and the DOM. Sites as quirksmode.org mention a couple of them, but I guess the best thing is to try to figure out the problem by yourself our ask here at the forums.


Bookmarks

Posting Permissions

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