1. Get a random number in a specific range
var x = Math.floor (Math.random () * (Max-min + 1)) + min;
2. Let the page automatically refresh once
function () { if (location.href.indexOf (' #reloaded ') = = = 1) {= location.href + "#reloaded "; Location.reload (); }}
3. Get the page back and refresh
Window.history.go ( -1); Window.location.reload ()
4. The form has only one input of the Enter submit questionIf you press ENTER when there is only one INPUT element in the form, the input element becomes the Submit type submission form. The blocking method is to add an input inside the form and hide it.
5. Determine if the image in the Web page is loaded, and call the method after the loading is complete
if (img.complete) { function() { // do something ... Else { function() { // do Something ... };}
6. Determine if the browser is IE
if (Navigator.userAgent.indexOf (' MSIE ') >-1) { alert (' you are using IE browser! ')}// Msie/chrome/firefox/opera
7. Page function Processing
//Screen Right-click menuDocument.oncontextmenu =function() {return false; } //Prohibit selectionDocument.onselectstart =function() {return false; } //Prohibit copyingdocument.getElementsByTagName (' body ') [0].oncopy =function() {return false; } //Prohibit clipping<input type= "text" oncut= "return false":>//Prevent //Prohibit paste<input type= "text" onpaste= "return false":>//prevent the current page from being imported into an IFRAMEif(Top.location!==self.location) {top.location=self.location;} //determine if the current page has an IFRAMEif(Window!==top) {Console.log (' Current page has iframe '); } //determine the source of the current page (from which page opens or jumps)Document.referrer
JavaScript Simple tips