I have a Java applet which displays an interactive map. By using the scroll wheel the user can zoom in/out of the map. Unfortunately the web browser (Firefox) also responds to the scroll events, and the applet ends up being scrolled off the visible page.
My question is, how can I prevent the browser from responding when the mouse is within the boundaries of the applet?
So far I’ve tried modifying my HTML to make the applet request focus
applet.focus()
I also tried adding a statement to my applet’s Java code like this
requestFocus();
But neither has resolved the problem.
I could add an specific zoom in/out control in the applet, or possibly restructure my web page to reduce the need for the web page to scroll, but it would be nice if the scroll wheel did the job of zooming the map only.
Use javascript and do something like this:
not this is untested code. might be a couple typos
EDIT like i said typos… I tested this and it works for sure:
Using the scroll method is not as clean but preventDefault didn’t seem to work…