This article describes how to use JS to capture the mouse wheel event, the principle is very simple, interested friends can refer to the following
Before seeing a senior front-end interview for Renren requirements Handwriting code, which has a problem is to do a photo show similar to Baidu pictures the bottom of the small thumbnail thumbnails that display bar And then ask for a mouse wheel rolling larger and smaller requirements This I really don't know how to do, look for information on the Internet Discovery can capture OnMouseWheel events Then according to the Event.wheeldelta value of the positive and negative to determine whether the roll forward or after the roll casually wrote a small example, by the way to capture the keyboard keys, not very beautiful no line because of the textnode do, add the HTML code Is it possible to prevent XSS injection in this way? Code as follows: <body onkeydown= "Showkey ()" Onmousewheel= "Showkey ()" > code as follows: function Showkey () { if (event.wheeldelta) { code as follows://positive 120 for roll forward minus 120 for roll var textnode = document.createTextNode (event.wheeldelta+ ""); Document.body.appendChild (textnode); Document.body.normalize (); } if (event.keycode) { var textnode = document.createTextNode ( Event.keycode+ ""); Document.body.appendChild (textnode); document.body.normalize (); } } One of the textnode elements that we just saw today in the advanced design. Merging multiple Textnode the code is as follows: Normalize ();