Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

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 02-22-2009, 08:16 PM   PM User | #1
`Jeremy
New Coder

 
Join Date: Feb 2009
Posts: 32
Thanks: 0
Thanked 4 Times in 4 Posts
`Jeremy is an unknown quantity at this point
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.
`Jeremy is offline   Reply With Quote
Old 02-23-2009, 04:31 AM   PM User | #2
A1ien51
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
A1ien51 will become famous soon enough
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]
A1ien51 is offline   Reply With Quote
Old 02-23-2009, 04:33 AM   PM User | #3
A1ien51
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
A1ien51 will become famous soon enough
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]
A1ien51 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 02:35 PM.


Advertisement
Log in to turn off these ads.