Home >Web Front-end >JS Tutorial >Collection of commonly used codes for beginners_Basic knowledge

Collection of commonly used codes for beginners_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 19:21:011535browse

This post mainly collects various introductory codes

Hiding and displaying layers

Just set the display attribute of style
For example,


If you want to display it, you can control it through script
window.document.getElementById("MyDiv").style.display = "";

Disable right click



Program running error in shielding page Information

window.onerror = function()
{
return true;
}

Get the resolution of the current monitor

window.srceen.width gets the width of the screen
window.srceen.height gets the height of the screen
If the current resolution is 800*600, window.srceen.width is 800, window.srceen. height is 600

Run specific code regularly

setTimeout(Code,Timeout);
setInterval(Code,Timeout);
Code is a string , inside is the js code, Timeout is the time interval, the unit is microseconds
setTimeout is how many microseconds from now to run the code (only runs once)
setInterval is how many microseconds to run the code

Get the URL of this page

var Url = window.location.href;

Save the content of the current page

document.execCommand("SaveAs","","C:\index.htm");

Hide the toolbar that pops up when the mouse is moved over the image in the browser

or



Open, save as, attribute, print" and other 14 JS codes

■Open■


■Save as■

■Properties■

■Print■

■Page Settings■

■Refresh■

■Import favorites■

■Export Favorites■

■Add to Favorites■

■Organize favorites■

■View original file■

■Language Settings■

■Forward■

■Back■

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