Link to home
Start Free TrialLog in
Avatar of campinam
campinam

asked on

JavaScript Events - Remove propagation of iframe wheel events to parent

When scrolling down the document in an iframe, and reach bottom, if keep spinning down the mouse wheel, the parent document starts scrolling. Browsers call it a "dispatch" of wheel event to parent. So it's not bubbling, as it's not within the same document. A new wheel event is created on parent.

Can this "dispatch" be prevented? How? (I use plain JavaScript.)
Is there any sample script available?
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of campinam
campinam

ASKER

Thank you! When you scroll the iframe to bottom, then spin the mouse wheel down some more, a lot more, and then immediately try to scroll up, it won't work (the inner iframe window won't scroll up). But wait a few seconds, and it will work.

Maybe the triggered events on parent window accumulate and it takes time to sort that out. What do you think?
because you are firing lots of javascripts and it takes some time to handle all those events :)

this is just hack to offset scroll by scrolling up :)

this is the best thing you can get I guess...

and actually you should not do such thing, since this is default browser behavior that users get used to it...
Users get used to it, but when the iframe is a modal on grayed-out parent, and when it was popped by some link on the parent, you don't want to lose the place you were on parent.

But I tried cancelling the wheel event on parent, while the iframe is up, and it won't do, unless you scroll outside the iframe. Maybe they fire some internal browser event with the "dispatch", not accessible in JavaScript? Would you know about that?
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Julian, thanks a lot! What an idea!!

Of course the background page (the parent) should stay frozen. Nothing could be better.

Really appreciate your help.
You are welcome.