Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 17:16:23
Original
1032 people have browsed it
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



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