Compatible with the JS Code added to favorites, compatible with the code added to favorites by Firefox, Google, and IE

Source: Internet
Author: User
Set as homepage JS, add to favorites js, add to favorites Code, set as homepage code, compatible with Firefox add to favorites and set as homepage, FF set as homepage JS, add to favorites js, add to favorites Code, set as homepage code, compatible with Firefox
Add to favorites and set as homepage, 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:

Html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN"
"Http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
Xmlns = "http://www.w3.org/5o/xhtml”>

Http-equiv = "Content-Type" content = "text/html; charset = gb2312 ″
/>
Compatible with FF, add to favorites, and set as Homepage
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 was rejected by the browser! \ N enter "about: config" in the address bar of the browser, press enter \ n, and then
Set the value of [signed. applets. codebase_principal_support] To 'true'. Double-click it .");

}
Var prefs =
Components. classes ['@ mozilla.org/preferences-service%1'%.getservice (Components. interfaces. nsIPrefBranch );

Prefs. setCharPref ('browser. startup. homepage', vrl );

}

}
}
//->
SCRIPT


Onclick = "AddFavorite (window. location, document. title)"> Add to favorites
Onclick = "SetHome (this, window. location)"> set as Homepage

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.