加入收藏夹:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function addFav(){
if(document.all){
window.external.addFavorite('http://127.0.0.1/111111/video.html','XXX网');
console.log( 'fvgdsfrg');
}else if(window.sidebar){
window.sidebar.addPanel('XXX网', 'http://127.0.0.1/111111/video.html','');
}
}
</script>
<a href="http://127.0.0.1/111111/video.html" title="XXXX网" rel="sidebar" onclick="addFav();">加入收藏</a></div>
<div style="border: 2px solid red; 80px;" onclick="addBookmark('dfsafasdfsa','http://127.0.0.1/111111/video.html')">加入收藏</div>
</body>
<script type="text/javascript">
function addBookmark(title, url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url, "");
}
else if (document.all) {
window.external.AddFavorite(url, title);
}
else if (window.opera && window.print) {
window.alert('dfsa');
return true;
}
}
</script>
</html>
打印:
<script> function printpage() { window.print() } </script> <input type="button" value="Print this page" onclick="printpage()">
设置首页:
function SetHome(obj, vrl) {
try {
obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl);
NavClickStat(1);
}
catch (e) {
if (window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch (e) {
alert("抱歉!您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[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);
}
}
}