js 屏蔽右键,加入收藏夹,设为主页

-----------------------------------------------------------------------------------------------------------------css

@charset "gb2312";
/* CSS Document */

body{
margin:0;
margin-top:3px;
padding:0;
font-size:12px;
line-height:20px;
color:#333;
}
.header{
margin-left:auto;
margin-right:auto;
width:720px;
}
.logo{
float:left;
width:600px;
}
.header_right{
width:120px;
color:#060;
text-decoration:none;
float:right;
cursor:pointer;
padding-top:15px;
}
.menu{
float:none;
clear:both;
}
.main{
width:95%;
margin-left:auto;
margin-right:auto;
}
.left_indent{
padding-left:20px;
}
.red{
color:#F00;
}

-----------------------------------------------------------------------------------------------------------------js

function setHomePages(){
/*if(document.all){*/
document.documentElement.style.behavior="url(#default#homepage)";
document.documentElement.setHomePage(‘http://www.ifindu.com.cn‘);
/*}
else if(window.sidebar){
 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", "http://www.ifindu.com.cn");
}*/
}
function addCookie(){//加入收藏夹
if(document.all){
window.external.addFavorite(‘http://www.ifindu.com.cn‘,‘六人行‘);
}
else if(window.sidebar){
window.sidebar.addPanel(‘六人行‘,‘http://www.ifindu.com.cn‘,‘‘);
}
}
function click(){
alert(‘您这是干什么呢?‘) //点击右键时,弹出警告框,屏蔽右键
return false;
}
document.oncontextmenu=click;

-----------------------------------------------------------------------------------------------------------------网页源码

<!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>JavaScript综合特效</title>

</head>

<body>
<div class="header">
<div class="logo"><img src="images/special_logo.gif" alt="logo"/>
&nbsp;&nbsp;
<img src="images/special_top.jpg" alt="top"/></div>
<div class="header_right"><!--<a onclick="this.style.behavior=‘url(#default#homepage)‘;this.setHomePage(‘http://www.ifindu.com.cn‘);return false;" > 【设为首页】</a>-->
<a onclick="setHomePages()"> 【设为首页】</a>
<br />
<a onclick="addCookie()">【收藏本站】</a>
</div>
<div class="menu"><img src="images/special_menu.jpg" alt="menu" /></div>
</div>
</body>
</html>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。