Before I saw a senior front-end interview for Renren
Require handwriting code, one of the problems is to do a picture show
Similar to Baidu picture the bottom small thumbnail that display bar
And then ask for a mouse wheel roll to change the size of the requirements
I really don't know how to do this, I looked for information on the Internet
Discovery of events that can capture OnMouseWheel
Then, according to the Event.wheeldelta value of the positive and negative to determine whether to roll forward or roll back
Casually wrote a small example, the way to capture the keyboard keys, not very beautiful no line
Because it's made with textnode, it doesn't add to the HTML code.
Is it possible to prevent XSS injection in this way?
Copy Code code as follows:
<body onkeydown= "Showkey ()" Onmousewheel= "Showkey ()" >
Copy Code code as follows:
function Showkey () {
if (Event.wheeldelta) {
Copy Code code as follows:
Positive 120 for roll forward minus 120 for roll back
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 ();
}
}
And it's just one of those textnode elements that you just saw today at the advanced design.
Ways to combine multiple Textnode
Copy Code code as follows: