Javascript-based browser menu command _ javascript skills

Source: Internet
Author: User
JS implementation browser menu command order: Although there is nothing technically involved in implementing menu commands using js, this is quite complete.

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] InJoin:
Open

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] InJoin:
Edit with notepad

3. Implementation of the "Save as" command

[Format]: document.exe cCommand ("saveAs ")
[Note] Save the webpage to another directory on the local disk!
[Example] InJoin:
Save

4. Implementation of the *** print *** command

[Format]: document.exe cCommand ("print ")
[Note] Of course, you must have installed a printer!
[Example] InJoin:
Print

5. Implementation of the "close" command

[Format]: window. close (); return false
[Note] This window will be closed.
[Example] InJoin:
Close this window


II. Implementation of commands in the [edit (E)] menu

Implementation of the command
[Format]: document.exe cCommand ("selectAll ")
[Description] All content on the webpage will be selected!
[Example] InJoin:
Select All

3. Implementation of commands in the [view (V)] menu

1. Implementation of the *** refresh *** command

[Format]: location. reload () or history. go (0)
[Note] the browser re-opens this page.
[Example] InJoin:
Refresh
Or join: refresh

2. Implementation of the command for source file

[Format]: location. replace ("view-source:" + location)
[Description] view the source code of the webpage.
[Example] InJoin:
View source files


3. Implementation of the "full screen display" command

[Format]: window. open (document. location, "url", "fullscreen ")
[Description] This page is displayed in full screen mode.
[Example] InJoin:
Full Screen Display


IV. Implementation of commands in the [add to Favorites (A)] menu

1. Implementation of the "add to Favorites" command

[Format]: window. external. AddFavorite ('url', 'site name ")
[Description] add this page to favorites.
[Example] InJoin:
Add to favorites

2. Implementation of the "Sort favorites" command

[Format]: window. external. showBrowserUI ("OrganizeFavorites", null)
[Description] The "Sort favorites" dialog box is displayed.
[Example] InJoin:
Sort favorites

V. Implementation of commands in the tool (T) menu

Implementation of the command "internet Options"

[Format]: window. external. showBrowserUI ("PrivacySettings", null)
[Description] the "internet Options" dialog box is displayed.
[Example] InJoin:
Internet Options


6. Implementation of commands in [toolbar]

1. Implementation of the [forward] command

[Format] history. go (1) or history. forward ()
[Note] the browser opens the next page.
[Example] InJoin:
Forward
Or join: Forward

2. Implementation of the "back" command

[Format]: history. go (-1) or history. back ()
[Description] the browser returns to the previous browsed page.
[Example] InJoin:
Back
Or join: Back

3. Implementation of the *** refresh *** command

[Format]: document. reload () or history. go (0)
[Note] the browser re-opens this page.
[Example] InJoin:
Refresh
Or join: refresh

7. Implementation of other commands

Implementation of the command to close this window at regular intervals
[Format]: settimeout (window. close (), closing time)
[Note] This window will be closed.
[Example] InJoin:
Close this window in 3 seconds
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.