1) puckpuckGroup: Members Posts: 1Joined: 23 Dec 2005Location: Windsor, ON, CanadaIP: 72.38.--.--
Posted:
Essentially the event object doesn't come through. So I made a real small fix for it, by adding a reference to the parent object (frame) and have the event object come through properly.
The problem occurs for me under IE 6 on win xp sp2. The main code is included in the parent frameset page. From the framed page itself, when it loads I leverage the parent page's function reference by doing this
parent.setupObjects();
In the parent page I would include the setupObjects function which creates a new layer on the framed page. It will also add event handlers to this layer.
When the event is fired my event object would be null, but I was able to do parent.frames.contentFrame.event to get a value. I didn't like having to hard code the parent object in my event handler just to reference the event. So my solution was to add a reference to the parent object through the addEvent function. I only did this to the non NS4 version, as I haven't had an NS4 browser hit my site in the past year.
New addEvent function with a reference to the parent object (p). The other addEvent function (NS4 version) must be commented out or you'll conflict due to identical function signatures (or add a parent reference to the NS4 version also).
function addEvent(o, p, n, f) { var a='addEventListener', h='on'+n; if (o[a]) return o[a](n, f, false); if (o[h]) { o._c |= 0; var b = '_b' + (++o._c); o[b] = o[h]; } o[h] = function(e) { p=p?p:self; e=e||p.event; var r = true; if (o[b]) r = o[b](e) != false && r; o._f=f; r = o._f(e) != false && r; return r; } };
2) Angus TurnbullGroup: Moderators Posts: 4042Joined: 7 Dec 2003Location: New ZealandIP: 210.54.--.--
Posted:
Good modification :). Yeah, by default addEvent() is designed more to be included in each frame where it's used, but that approach is a perfectly valid tweak.