<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>支持IE6和火狐最新版的JS添加首頁、收藏夾</title>
</head>
<body>
<script type="text/javascript">
function homePage(obj,val){
try{
obj.style.behavior='url(#default#homepage)';
obj.setHomePage(val);
}
catch(e){
if(window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch (e) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
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',val);
}
}
}
function addFavorite() {
var a = document.URL.split("/");
var c = "http://" + a[2] + "/";
var b = document.title;
try {
window.external.AddFavorite(c, b)
} catch (d) {
window.sidebar.addPanel(b, c, "")
}
};
</script>
<a href="#"onclick="homePage(this,'www.hao123.com')" >設爲首頁JAVAEYE</a>
<span title="將多玩遊戲網加入收藏夾" onclick="addFavorite();" style="cursor:pointer">加入收藏</span>
</body>
</html>
主頁和收藏網頁代碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.