Implement some menu commands of IE browser

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 ")
[Description] All content on the webpage will be selected!
[Example] Add the following content between <body> </body>:
<A href = "#" onclickappsdocument.exe ccommand ("selectall")> select all </a>

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] Add the following content between <body> </body>:
<A href = "#" onclick = location. Reload ()> refresh </a>
Or add: <a href = "#" onclick = history. Go (0)> refresh </a>

2. Implementation of the command for source file

[Format]: location. Replace ("view-source:" + location)
[Description] view the source code of the webpage.
[Example] Add the following content between <body> </body>:
<A href = "#" onclick = location. Replace ("view-source:" + location)> View source files </a>

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] Add the following content between <body> </body>:
<A href = "#" onclick = Window. Open (document. Location, "url", "fullscreen")> full screen display </a>

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] Add the following content between <body> </body>:
<A href = "javascript: window. External. AddFavorite ('HTTP: // oh.jilinfarm.com ', 'huming new homepage')"> Add to favorites </a>

2. Implementation of the "Sort favorites" command

[Format]: window. External. showbrowserui ("organizefavorites", null)
[Description] The "Sort favorites" dialog box is displayed.
[Example] Add the following content between <body> </body>:
<A href = "#" onclick = Window. External. showbrowserui ("organizefavorites", null)> sort favorites </a>

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] Add the following content between <body> </body>:
<A href = "#" onclick = Window. External. showbrowserui ("privacysettings", null)> Internet Options </a>

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] Add the following content between <body> </body>:
<A href = "#" onclick = history. Go (1)> forward </a>
Or join: <a href = "#" onclick = history. Forward ()> forward </a>

2. Implementation of the "back" command

[Format]: history. Go (-1) or history. Back ()
[Description] the browser returns to the previous browsed page.
[Example] Add the following content between <body> </body>:
<A href = "#" onclick = history. Go (-1)> back </a>
Or add: <a href = "#" onclick = history. Back ()> back </a>

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

[Format]: Document. Reload () or history. Go (0)
[Note] the browser re-opens this page.
[Example] Add the following content between <body> </body>:
<A href = "#" onclick = location. Reload ()> refresh </a>
Or add: <a href = "#" onclick = history. Go (0)> refresh </a>

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] Add the following content between <body> </body>:
<A href = "#" onclick = setTimeout (window. Close (), 3000)> close this window in 3 seconds </a>

If you have compiled other commands implemented using JavaScript, you may wish to share them with us.

[Appendix] for the convenience of readers, we will list all the instance codes below. You can put them in an HTML file and then preview the results. Download HTML files.

<A href = "#" onclickappsdocument.exe ccommand ("open")> open </a> <br>
<A href = "#" onclick = location. Replace ("view-source:" + location)> edit with notepad </a> <br>
<A href = "#" onclickappsdocument.exe ccommand ("saveas")> Save As </a> <br>
<A href = "#" onclickappsdocument.exe ccommand ("print")> Print </a> <br>
<A href = "#" onclick = Window. Close (); Return false)> close this window </a> <br>
<A href = "#" onclickappsdocument.exe ccommand ("selectall")> select all </a> <br>
<A href = "#" onclick = location. reload ()> refresh </a> <a href = "#" onclick = history. go (0)> refresh </a> <br>
<A href = "#" onclick = location. Replace ("view-source:" + location)> View source files </a> <br>
<A href = "#" onclick = Window. Open (document. Location, "url", "fullscreen")> full screen display </a> <br>
<A href = "javascript: window. External. AddFavorite ('HTTP: // homepage.yesky.com ', 'tianji webpage taoba')"> Add to favorites </a> <br>
<A href = "#" onclick = Window. External. showbrowserui ("organizefavorites", null)> sort favorites </a> <br>
<A href = "#" onclick = Window. External. showbrowserui ("privacysettings", null)> Internet Options </a> <br>
<A href = "#" onclick = history. go (1)> forward 1 </a> <a href = "#" onclick = history. forward ()> Qianjin 2 </a> <br>
<A href = "#" onclick = history. go (-1)> 1 </a> <a href = "#" onclick = history. back ()> 2 </a> <br>
<A href = "#" onclick = setTimeout (window. Close (), 3000)> close this window in 3 seconds </a> <br>

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.