We often encounter this situation when doing development: a.swf is added to the web page. There are scroll bars on both a.swf and html pages. The project manager proposed a BT requirement --- when the mouse scrolls a.swf, the html page does not scroll, otherwise the html page scrolls! What should be done? Method 1 : 1. When the mouse moves into the scrolling area of a.swf: tell JS to remove the browser mouse scrolling monitor. 2. When the mouse moves out of the scrolling area of a.swf: tell JS to add a browser mouse scroll listener. 3.a.swf's wmode is set to "window". Summary: Setting wmode to "window" may not meet project requirements, which makes a.swf cover any html page below it; in addition, when the mouse moves into the scrolling area of a.swf and presses Alt+Tab to switch pages, JS is not notified to add browser mouse scrolling monitoring, so after the operation, there is no scrolling processing when switching back to the html page Method 2 : 1. a.swf cancels its own mouse scrolling monitoring event and adds a scrolling processing interface for JS to call, such as wheelToFlash(value). 2. When the mouse moves into the scrolling area of a.swf: inform JS, for example, mouseIsInFlashWheelRange=true. 3. When the mouse moves out of the scrolling area of a.swf: inform JS, for example, mouseIsInFlashWheelRange=false; 4.JS monitors mouse scroll events. In the event monitoring 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, value is the scroll value of HTML scroll table*/ document.getElementById("flashID").wheelToFlash(value); /**Prevent bubbling of mouse events on HTML pages, usually event.preventDefault()*/ event.preventDefault(); } else { /**Handle normal scrolling of HTML, we don't need to do anything*/ } Summary : Compared with method 1, there is no restriction of wmode="window"; the Alt+Tab problem still exists. Note : When writing JS code, we need to pay attention to compatibility issues. Different browsers listen to mouse events and obtain scroll values differently! |
<<: Detailed explanation of Linux using ss command combined with zabbix to monitor socket
>>: Implement QR code scanning function through Vue
What is element-ui element-ui is a desktop compon...
cursor A cursor is a method used to view or proce...
Copy code The code is as follows: <div style=&...
Using iframes can easily call pages from other we...
This article uses an example to illustrate the us...
Operation effectCode Implementation html <div ...
Table of contents Business scenario: Effect demon...
When I turned on my MAC at night, I found that th...
MySQL Query Cache is on by default. To some exten...
As the most commonly used layout element, DIV play...
2048 mini game, for your reference, the specific ...
This article shares the specific code for JavaScr...
Table of contents Preface Install vue-i18n Config...
Nginx global variables There are many global vari...
When I was helping someone adjust the code today,...