JS 设为首页 加入收藏
<html><head><meta http-equiv="Content-Type" content="text html; charset=utf-8" ><title>JS 设为首页 加入收藏 - 免费教程
天晟网小编整理编程教程 > JavaScript > 时看到JS 设为首页 加入收藏 ,下面有小编47为你找到的38045相关内容希望对你47有所帮助。
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS 设为首页 加入收藏 - 免费教程
- www.timsion.com</title>
<script type="text/javascript">
//设为首页(函数)
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("此操作被浏览器拒绝!n请在浏览器地址栏输入“about:config”并回车n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage',vrl);
}
}
}
// 加入收藏(函数)
function AddFavorite(sURL, sTitle){
try{
window.external.addFavorite(sURL, sTitle);
}
catch (e){
try{
window.sidebar.addPanel(sTitle, sURL, "");
}
catch (e){
alert("加入收藏失败,请使用Ctrl+D进行添加");
}
}
}
</script>
</head>
<body>
<a href="javascript:void(0)" onclick="SetHome(this,window.location)">设为首页</a>
<a href="javascript:void(0)" onclick="AddFavorite(window.location,document.title)">加入收藏</a>
</body>
</html>
文章转载请注明来自天晟网 > 编程教程 > JavaScript >
原文标题:JS 设为首页 加入收藏
原文网址:http://www.timsion.com/javas/38045.html
上一篇:JS显示当前动态时间
下一篇:JavaScript实现网站页面打印功能
免责声明:以上内容来自互联网和用户投稿,不代表本站的观点和立场,版权归原作者所有,如有侵权,请与我们联系。