Getting started with common code

Source: Internet
Author: User

This post mainly collects various beginner codes.

Hide and display Layers

You only need to set the display attribute of the style.
For example, <div style = "display: none" id = "MyDiv"> hidden layer </div>
You can use scripts to control the display.
Invalid variable Doc ument. getElementById ("MyDiv"). style. display = "";

Disable right-click

<Body oncontextmenu = "return false">

Blocking program running error information on the page

Window. onerror = function ()
{
Return true;
}

Obtains the resolution of the current display.

Window. srceen. width to get the screen width
Window. srceen. height to get the screen height
If the current resolution is 800*600, the window. srceen. width is 800, and the window. srceen. height is 600.

Regularly run specific code

SetTimeout (Code, Timeout );
SetInterval (Code, Timeout );
Code is a string with js Code in it and Timeout in microseconds.
SetTimeout is the number of microseconds from now before the code is run (only once)
SetInterval is the number of microseconds to run the code

Get the URL of this page

Var Url = window. location. href;

Save the content of the current page

Document.exe cCommand ("SaveAs", "", "C: \ index.htm ");Hide the toolbar in the browser that jumps out when the mouse moves to the image

Or
<Head>
<Meta http-equiv = "imagetoolbar" content = "no">
</Head>
Open, save as, attribute, print, and other 14 JS Code

■ Enable ■
<Input name = Button onClick = document. all. WebBrowser. ExecWB (1,1) type = button value = open>
<OBJECT classid = CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2 height = 0 id = WebBrowser width = 0> </OBJECT>
■ Save As ■
<Input name = Button onClick = document. all. webBrowser. execWB (4,1) type = button value = Save As> <OBJECT classid = CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2 height = 0 id = WebBrowser width = 0> </OBJECT>
■ Attribute ■
<Input name = Button onClick = document. all. webBrowser. execWB (10, 1) type = button value = property> <OBJECT classid = CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2 height = 0 id = WebBrowser width = 0> </OBJECT>
■ Print ■
<Input name = Button onClick = document. all. webBrowser. execWB (6, 1) type = button value = print> <OBJECT classid = CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2 height = 0 id = WebBrowser width = 0> </OBJECT>
■ Page settings ■
<Input name = Button onClick = document. all. webBrowser. execWB (8, 1) type = button value = page Settings> <OBJECT classid = CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2 height = 0 id = WebBrowser width = 0> </OBJECT>
■ Refresh ■
<Input type = button value = refresh name = refresh onclick = "window. location. reload ()">
■ Import to favorites ■
<Input type = "button" name = "Button" value = "Import favorites" onClick = window. external. ImportExportFavorites (true,);>
■ Export to favorites ■
<Input type = "button" name = "Button3" value = "Export favorites" onClick = window. external. ImportExportFavorites (false,);>
■ Add to favorites ■
<INPUT name = Button2 onclick = "window. external. AddFavorite (location. href, document. title)" type = button value = add to favorites>
■ Sort favorites ■
<INPUT name = Submit2 onclick = "window. external. ShowBrowserUI (OrganizeFavorites, null)" type = button value = favorites>
■ View the original file ■
<INPUT name = Button onclick = window. location = "view-source:" + window. location. href type = button value = view source File>
■ Language settings ■
<INPUT name = Button onclick = "window. external. ShowBrowserUI (LanguageDialog, null)" type = button value = language Settings>
■ Qianjin ■
<INPUT name = Submit onclick = history. go (1) type = submit value = forward>
■ Retreat ■
<INPUT name = Submit2 onclick = history. go (-1) type = submit value = back>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.