If you want to be compatible with multiple browsers, you should judge the user's browser type, if it is Firefox or ie6,7,8, and so on, so that they can not be judged by the difference between the operation.
<html xmlns= "http://www.w3.org/1999/xhtml" > <head runat= "Server" > <title> Untitled page </ title> <script language= "Web Effects" type= "Text/javascript" > function Addfavorite (sURL, Stitle) { Try { Window.external.addfavorite (sURL, stitle); } catch (e) { Try { Window.sidebar.addpanel (stitle, sURL, ""); } catch (e) { Alert ("Failed to join the collection, please use CTRL to add"); } } } function Sethome (OBJ,VRL) { try{ obj.style.behavior= ' url (#default #homepage) '; o Bj.sethomepage (VRL); } catch (e) { if (window.netscape) { try { Netscape.security.privilegemanager.enableprivilege (" Universalxpconnect "); } catch (e) { Alert ("This operation is rejected by the browser!") n Please enter "About:config" in the browser address bar and return to n then set the value of [Signed.applets.codebase_principal_support] to ' true ' and double-click. "); } var prefs = components.classes[' @mozilla. Org/preferences-service;1 '].getservice ( Components.interfaces.nsiprefbranch); Prefs.setcharpref (' Browser.startup.homepage ', VRL); } } } </script>
Add to Favorites function Addtofavorite () { if (document.all) { Window.external.addfavorite (Document.url,document.title); }else if (Window.sidebar) { Window.sidebar.addpanel (Document.title, Document.url, ""); } }
//Set as homepage Function sethomepage () { if (document.all) { Document.body.style.behavior= ' url (#default #homepage) '; document.body.sethomepage (Document.url); }else if (window.sidebar) { if (window.netscape) { try{ Netscape.security.privilegemanager.enableprivilege (" Universalxpconnect "); }catch (e) { alert ("This action is rejected by the browser, and if you want to enable this feature, Please enter about:config in the Address bar and then signed.applets.codebase_principal_support the value to true "); } } var prefs = components.classes[' @mozilla. Org/preferences-service;1 '].getservice (rs. Interfaces.nsiprefbranch); prefs.setcharpref (' Browser.startup.homepage ', document.url); } } Calling method
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.