Home >Web Front-end >HTML Tutorial >Analysis and processing methods of scroll bars existing in both html and flash embedded in it_HTML/Xhtml_Web page production

Analysis and processing methods of scroll bars existing in both html and flash embedded in it_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:40:341262browse

We often encounter this situation when developing:
a.swf is added to the web page, a.swf and html pages have scroll bars at the same time, and the project manager raised a BT requirement---process a. When the swf mouse is scrolled, the html page does not scroll. Otherwise, the html page scrolls!
What should be done?
Method 1:
1. Move the mouse into a.swf to scroll area: Tell JS to remove the browser mouse scrolling monitor.
2. When the mouse moves out of the a.swf scrolling area: Tell JS to add the browser mouse scrolling monitor.
3. The wmode of a.swf is set to "window".
Summary: Setting wmode to "window" may not meet the project requirements, which makes a.swf block any html page below it; in addition, press Alt Tab after moving the mouse into the a.swf scroll area When switching pages, JS is not notified to add browser mouse scroll monitoring, so there is no scroll processing when switching back to the html page after the operation

Method 2:
1.a. swf cancels its own mouse scrolling listening event, and adds a scrolling processing interface for JS to call, such as wheelToFlash(value).
2. When the mouse moves into the a.swf scrolling area: inform JS, for example, mouseIsInFlashWheelRange=true.
3 .When the mouse moves out of the a.swf scrolling area: inform JS, for example, mouseIsInFlashWheelRange=false;
4.JS listens to mouse scrolling events. In the event listening processing function, we need to make the following judgments
Javascript code:

Copy code
The code is as follows:

if(mouseIsInFlashWheelRange==true)
{
/**Call the interface provided by a.swf to make a.swf simulate scrolling*/
/**"flash" is the ID of a.swf embedded in html, and value is the value of html scroll table scrolling*/
document.getElementById("flashID").wheelToFlash(value);
/**Prevent the bubbling of mouse events on the html page, usually event.preventDefault()*/
event.preventDefault();
}
else
{
/**To handle normal scrolling of html, we don’t need to do anything*/
}

Summary: Compared with method 1, there is no limitation of wmode="window"; the problem of Alt Tab still exists.
Note: When writing JS code, we need to pay attention to compatibility issues. Different browsers monitor mouse events and obtain scrolling values ​​differently!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn