DHTML Forum  

Go Back   DHTML Forum > dhtmlcentral.com > Crossbrowser DHTML
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 28.04.2005, 00:27
Garrett Smith Garrett Smith is offline
Erfahrener Benutzer
 
Join Date: 25.05.2001
Location:
Posts: 808
Default

When you use attachEvent, the fpNotify is executed in global scope.
[code:kl73t3exye]
function handleClick() {
alert(this == document.body);
alert(event.srcElement == document.body);
}

document.body.attachEvent("onclick", handleClick);[/code:kl73t3exye]

Since IE is really lame, they left out currentTarget (a fly on the pile of shit that is IE's event model).

I can check the srcElement to see what I clicked on, but sometimes we design things with a certain level of abstraction where we don't know the element that the handler was assigned to. The srcElement might be deeply nested in the currentTarget (which doesn't exist in IE). The currentTarget has no uniquely identifying information (other than the fact that it is the one that the event-hook notified, of course).

Theres probably a few stupid hacky ways I could "make it work". But they all require code redesign and the code at this point is not wanting that at all.

Simple workaround?


http://dhtmlkitchen.com/ - The best DHTML website!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 28.04.2005, 11:10
Mark Mark is offline
Erfahrener Benutzer
 
Join Date: 28.02.2002
Location: Netherlands
Posts: 2.853
Default

Use a closure to keep the reference to the node. You'll run into memory leakage problems then, though.

- [url="http://neo.dzygn.com/"]Mark[/url:m6qooemcac]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 28.04.2005, 18:00
Garrett Smith Garrett Smith is offline
Erfahrener Benutzer
 
Join Date: 25.05.2001
Location:
Posts: 808
Default

That's really funny, Mark. The way to solve the problem, and it introduces a mem leak. I know exactly what you mean, too.

[code:bupun2266i]el.attachEvent("onclick", function() { alert(el.tagName); });[/code:bupun2266i]

js function -> el -> js function, or something like that.

==
Well, I'm working on a listener class that can handle that. It is about 50 lines of code. I hate doing this. I hate writing workarounds that should not be necessary.

The good news is that the listener class I'm working on works for custom objects, too. It should be pretty efficient, theoretically. It works well, but I have to test for memory leaks in IE and right now, I don't have IE. I may need to use a cleanup onunload. Hopefully not.

God, I hate IE.





http://dhtmlkitchen.com/ - The best DHTML website!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 29.04.2005, 10:05
Tim Scarfe Tim Scarfe is offline
Erfahrener Benutzer
 
Join Date: 14.05.2001
Location: United Kingdom
Posts: 1.015
Default

God I hate shitfox

--
Regards,
Tim Scarfe <dc@developer-x.com>
http://www.developer-x.com
http://www.dotnetsolutions.ltd.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 29.04.2005, 19:02
Garrett Smith Garrett Smith is offline
Erfahrener Benutzer
 
Join Date: 25.05.2001
Location:
Posts: 808
Default

There's a guy here at work just like that. He loves IE. I asked him: "So what about IE do you like?"

He said: "99% of all users use IE!" (this is not true) and then "Well, I don't see why we need more than one browser, and most people have IE." and then "I don't know why anyone needs to do something weird. I just want to do normal things in browsers."

So I said: "Yeah, I like to do normal things, too. I like to use "width" and "height" and "display", but IE doesn't support any of these things."

He just got a virus from IE and last I saw, he was still in safe mode.




http://dhtmlkitchen.com/ - The best DHTML website!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 29.04.2005, 20:35
Tim Scarfe Tim Scarfe is offline
Erfahrener Benutzer
 
Join Date: 14.05.2001
Location: United Kingdom
Posts: 1.015
Default

And you are comparing this clueless guy to me?

--
Regards,
Tim Scarfe <dc@developer-x.com>
http://www.developer-x.com
http://www.dotnetsolutions.ltd.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7  
Old 30.04.2005, 14:31
Mark Mark is offline
Erfahrener Benutzer
 
Join Date: 28.02.2002
Location: Netherlands
Posts: 2.853
Default

Hmm, you have other arguments then, Tim? ;-)

- [url="http://neo.dzygn.com/"]Mark[/url:s0qw3iuxpp]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8  
Old 01.05.2005, 02:36
Tim Scarfe Tim Scarfe is offline
Erfahrener Benutzer
 
Join Date: 14.05.2001
Location: United Kingdom
Posts: 1.015
Default

It's the principle of the thing

--
Regards,
Tim Scarfe <dc@developer-x.com>
http://www.developer-x.com
http://www.dotnetsolutions.ltd.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9  
Old 01.05.2005, 05:58
Garrett Smith Garrett Smith is offline
Erfahrener Benutzer
 
Join Date: 25.05.2001
Location:
Posts: 808
Default

<blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">Originally posted by Tim Scarfe

And you are comparing this clueless guy to me?

--
Regards,
Tim Scarfe <dc@developer-x.com>
http://www.developer-x.com
http://www.dotnetsolutions.ltd.uk
<hr id="quote"></blockquote id="quote"></span id="quote">

No, not trying to compare; just some random coincidental though association. I was tired that day and it just popped into my head; kinda click. Well I'm tired almost every day because I work my ass of at work and I exercise 13x/wk (on avg). But now that I think of it, I don't think he has the ability to be as obnoxious as you



http://dhtmlkitchen.com/ - The best DHTML website!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10  
Old 01.05.2005, 12:17
Tim Scarfe Tim Scarfe is offline
Erfahrener Benutzer
 
Join Date: 14.05.2001
Location: United Kingdom
Posts: 1.015
Default

Great, glad we cleared that that one up!

--
Regards,
Tim Scarfe <dc@developer-x.com>
http://www.developer-x.com
http://www.dotnetsolutions.ltd.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT +2. The time now is 07:13.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.