Home >Web Front-end >JS Tutorial >A small example of setting the homepage and favorite pages with JavaScript_javascript skills

A small example of setting the homepage and favorite pages with JavaScript_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:16:231051browse
Copy code The code is as follows:



> //url: link to favorite; title: name of favorite item
function AddFavorite(url,title)
{
//If url or title is empty, the default is the current page url and title.
if(!(url&&title))
url=document.URL; title=document.title;
}

If (document.all)// IE
                                                                                                       . window.sidebar.addPanel(title , url, "");
                                                                                                                                Is empty and defaults to the current page URL.
if(!url)
{
url=document.URL;
} }

if (document.all)//IE
{
document.body .style.behavior = 'url(#default#homepage)';
document.body.setHomePage(url);
}
else if (window.sidebar)//Firefox
{
if (window.netscape)
{
try
{
window.netscape.security.PrivilegeManager.enablePrivilege ("UniversalXPConnect");
                                                                                                                                       >                                                                    . ");
          }                                                                                                  Prefs. setCharPref('browser.startup.homepage', url);
            }                        onClick="SetHomepage('http://www.jb51.net/')" title="Set as homepage" href="javascript:">Set as homepage
Collection



Statement:
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