Use Javascript to implement browser menu commands

Source: Internet
Author: User
When we see links on other people's web pages that enable, print, forward, save as, back, close this window, disable right-click, and so on to implement browser commands, are you sorry? Do you also want to implement it? It would be interesting to implement browser commands on the webpage! Next, let's take a look at how to use Javascript code to implement browser menu commands (the following code is successfully debugged in a Windows XP browser ).
1. Implementation of commands in the [File (F)] menu
1. Implementation of the Open Command
[Format]: document.exe cCommand ("open ")
[Note] this is similar to the webbrowser control commands in programming design such as VB. You can also consider it here.
[Example] add the following content between <body> </body>:
<A href = "#" onclickappsdocument.exe cCommand ("open")> open </a>
2. Implementation of the command 'use notepad edit'
[Format]: location. replace ("view-source:" + location)
[Note] Open Notepad and show the source code of the webpage in Notepad.
[Example] add the following content between <body> </body>:
<A href = "#" onclick = location. replace ("view-source:" + location)> edit with notepad </a>
3. Implementation of the "save as" command
[Format]: document.exe cCommand ("saveAs ")
[Note] Save the webpage to another directory on the local disk!
[Example] add the following content between <body> </body>:
<A href = "#" onclickappsdocument.exe cCommand ("saveAs")> save as </a>
4. Implementation of the *** print *** command
[Format]: document.exe cCommand ("print ")
[Note] of course, you must have installed a printer!
[Example] add the following content between <body> </body>:
<A href = "#" onclickappsdocument.exe cCommand ("print")> print </a>
5. Implementation of the "close" command
[Format]: window. close (); return false
[Note] this window will be closed.
[Example] add the following content between <body> </body>:
<A href = "#" onclick = window. close (); return false)> close this window </a>
II. Implementation of commands in the [edit (E)] menu
Implementation of the command
[Format]: document.exe cCommand ("selectAll ")

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.