100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > js代码 设为首页 加入收藏

js代码 设为首页 加入收藏

时间:2023-01-21 18:16:19

相关推荐

js代码 设为首页 加入收藏

// JavaScript Document// 加入收藏 <a οnclick="AddFavorite(window.location,document.title)">加入收藏</a>function AddFavorite(sURL, sTitle){try{window.external.addFavorite(sURL, sTitle);}catch (e){try{window.sidebar.addPanel(sTitle, sURL, "");}catch (e){alert("加入收藏失败,请使用Ctrl+D进行添加");}}}//设为首页 <a οnclick="SetHome(this,window.location)">设为首页</a>function SetHome(obj,vrl){try{obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);}catch(e){if(scape) {try {netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}catch (e) {alert("此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");}var prefs = Components.classes['@/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);prefs.setCharPref('browser.startup.homepage',vrl);}}}

使用

<a href="#" οnclick="SetHome(this,window.location)" >设为首页</a>

<a href="#" οnclick="AddFavorite(window.location,document.title)" >收藏本站</a>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。