Home > Web Front-end > JS Tutorial > JS code to add to favorites (common to mainstream browsers)_javascript skills

JS code to add to favorites (common to mainstream browsers)_javascript skills

WBOY
Release: 2016-05-16 17:33:57
Original
1163 people have browsed it

Common js code for all browsers to add favorites

Copy code The code is as follows:

< script>
function addfavorite()
{
if (document.all)
{
window.external.addFavorite('http://www.XXX.com','XXX' );
}
else if (window.sidebar)
{
window.sidebar.addPanel('XXX', 'http://www.XXX.com', "");
}
}

XXX

Open, save as, attribute, print" and other 14 JS codes
■Refresh■
■Import favorites■
■Export favorites■
■Organize favorites■
■View Original file■
■Language settings■
■Open■


■Save As■
340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0>< ;/OBJECT>
■Properties■
340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0>
■Print■
340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0>
■ Page Settings■
-340A-11D0 -A96B-00C04FD705A2 height=0 id=WebBrowser width=0>
■Refresh■

■Import Favorites■

■Export Favorites■

■Add to Favorites■

■Organize favorites■

■View original file■

■Language settings■

■Forward■

■Back■
< ;INPUT name=Submit2 onclick=history.go(-1) type=submit value=Back>
- Author: gatebill November 1, 2005, Tuesday 12:42 Reply (0) | Quote (0) Join Bocai
JS implements browser menu commands
Whenever we see links on other people’s web pages that implement browser commands such as open, print, forward, save as, back, close this window, disable right-click, etc., but ourselves Do you feel regretful when you are unable to achieve it
? Do you also want to achieve it? How interesting it would be if browser commands could be implemented on the web page! Let's take a look at how to use
Javascript code to implement browser menu commands (the following code has been debugged in the browser under Windows XP).

1. Implementation of the command in the [File (F)] menu
1. Implementation of the 〖Open〗 command
[Format]: document.execCommand("open ")
[Explanation] This is somewhat similar to the commands in the webbrowser control in VB and other programming designs. You can also think about it based on this.
[Example] Add between :
Open
2. Implementation of the "Edit with Notepad" command
[Format]:location.replace("view-source:" location)
[Description] Open Notepad and display the page information in Notepad source code.
[Example] Add between :
Use Notepad Edit
3. Implementation of the [Save As] command
[Format]: document.execCommand("saveAs")
[Description] Save the web page to another directory on the local disk!
[Example] Add between :
Save as
4. Implementation of the [Print] command
[Format]: document.execCommand("print")
[Explanation] Of course, you must have a printer installed!
[Example] Add between :
Print
5. Implementation of the 〖Close〗 command
[Format]: window.close(); return false
[Explanation] This window will be closed.
[Example] Add between :
Close this window

2. Implementation of the command in the [Edit (E)] menu
Implementation of the "Select All" command
[Format]: document.execCommand(" selectAll")
[Description] All content in the webpage will be selected!
[Example] Add between :
Select all

3. Implementation of the command in the [View (V)] menu
1. Implementation of the "Refresh" command
[Format]: location.reload() or history.go(0)
[Description] Reopen this page in the browser.
[Example] Add between :
Refresh
or Add:Refresh
2. Implementation of the 〖Source File〗 command
[Format]:location.replace(" view-source:" location)
[Description] View the source code of this web page.
[Example] Add between :
View source file
3. Implementation of the 〖Full Screen Display〗 command
[Format]:window.open(document.location,"url","fullscreen")
[Description] Display this page in full screen .
[Example] Add between :


4. Implementation of the commands in the [Favorites (A)] menu
1. Implementation of the "Add to Favorites" command
[Format]:window.external.AddFavorite('url', '"Website Name")
[Description] Add this page to favorites.
[Example] Add between :
http://oh.jilinfarm.com', 'Hu Mingxin's personal homepage')">Add to Favorites
2. Implementation of the "Organize Favorites" command
[Format]:window.external.showBrowserUI("OrganizeFavorites",null)
[Description] Open the organize favorites dialog box
[Example] Add: Organize favorites


5. [Tools (T) 】Implementation of commands in the menu
Implementation of 〖internet options〗 command [Format]: window.external.showBrowserUI("PrivacySettings",null)
[Description] Open the internet options dialog box .
[Example] Add between :
internet option


6. Implementation of commands in [Toolbar]
1. Implementation of [Forward] command [Format] history.go(1 ) or history.forward()
[Explanation] The browser opens the next page.
[Example] Add:
Forward
Or join:Forward
2 , Implementation of the [Back] command
[Format]: history.go(-1) or history.back()
[Explanation] The browser returns to the previous browsed page.
[Example] Add between :
Back
Or add:Back
3. Implementation of 〖Refresh〗
[Format]:document.reload() Or history.go(0)
[Instructions] Reopen this page in the browser.
[Example] Add between :
Refresh
or Add:Refresh


7. Implementation of other commands
〖Timed shutdown Implementation of this window〗 command [Format]: settimeout(window.close(), closing time)
[Explanation] This window will be closed.
[Example] Add between :
Close this window in 3 seconds
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template