Set JS as the homepage, add favorites, Firefox and IE compatibility

Source: Internet
Author: User

Set as homepage JS, add to favorites JS, add to favorites Code, set as homepage code, Firefox is compatible with IE

Keywords: set as homepage JS, add to favorites JS, add to favorites Code, set as homepage code, compatible with Firefox, add to favorites, set as homepage, and FF as Homepage
In one setting, I found that Firefox (FF) does not support adding favorites and setting them as the homepage like IE, so I found the FF method. Then I tested it and can use it .. The Code is as follows:

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> compatible with FF, add to favorites, and set as homepage </title>
<Script language = "JavaScript">
<! --
Function AddFavorite (Surl, stitle)
{
Try
{
Window. External. AddFavorite (Surl, stitle );
}
Catch (E)
{
Try
{
Window. Sidebar. addpanel (stitle, Surl ,"");
}
Catch (E)
{
Alert ("failed to add to favorites, please add with Ctrl + D ");
}
}
}
Function sethome (OBJ, VRL ){
Try {
OBJ. style. Behavior = 'url (# default # homepage) '; obj. setHomePage (VRL );
}
Catch (e ){
If (window. Netscape ){
Try {
Netscape. Security. privilegemanager. enableprivilege ("universalxpconnect ");
}
Catch (e ){
Alert ("this operation is rejected by the browser! \ N enter "about: config" in the address bar of the browser, press enter \ n, set the value of [signed. Applets. codebase_principal_support] To 'true', and double-click it. ");
}
VaR prefs = components. classes ['@ mozilla.org/preferences-service%1'}.getservice (components. Interfaces. nsiprefbranch );
Prefs. setcharpref ('browser. startup. homepage', VRL );
}
}
}
// -->
</SCRIPT>
</Head>
<Body>
<A onclick = "AddFavorite (window. Location, document. Title)"> Add to favorites </a>
<A onclick = "sethome (this, window. Location)"> set as homepage </a>
</Body>
</Html>

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.