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 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    32
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Onclick Event Hander / Internet Explorer Compatibility

    My first issue is that I need to be able to have my script change the onclick event in both Firefox and Internet Explorer. However, Internet Explorer has been a jerk about this issue. The only method that works in IE that I have found so far is document.getElementById('div'+id).onclick = function () { functionName(id); };. Unfortunately, this method does not work because I need to loop this command. In doing so, it leaves all of the onclicks' paramaters to be whatever id was last set to in the loop.

    ----

    My second issue is hiding table rows. I'm looping this line: if (document.getElementById('queue'+id)) document.getElementById('queue'+id).className = 'noshow';. The CSS for noshow is .noshow {display:none;}. However, IE doesn't seem to want to hide the rows sometimes, but FF always does.

    Any help for either issue is much appreciated.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Well an easy solution is to use this

    Code:
    document.getElementById('div'+id).onclick = function () { functionName(this.id); };
    If you check out my post here: http://www.coderanch.com/t/119917/HT...losures#594446 You can see solutions to make it work without using this [but using "this" is your best solution]

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    For your second issue, have you used the Web Developer Toolbar and inspect the elements that are not being hidden and see if the class is being added?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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