1、屏蔽右键
2、设计为首页,添加收藏
3、打印本页
<input id="btnPrint" type="button" value="打印" onclick="javascript:window.print();" />
打印区域 :
<script>
function printarea(oper) {
if (oper < 10){
bdhtml=window.document.body.innerHTML;//获取当前页的html代码
sprnstr="<!--startprint-->";//设置打印开始区域
eprnstr="<!--endprint-->";//设置打印结束区域
prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
window.document.body.innerHTML=prnhtml;
window.print();
window.document.body.innerHTML=bdhtml;
} else{
window.print();
}
}
</script>
4、复制链接
function copyToClipboard()
{
var ch=document.location;
ch +='\r\n';
<!--var ch=a.value;-->
window.clipboardData.setData("Text",ch);
alert("已复制链接");
}
5、判断浏览器、
function getExplorer() {
var explorer = window.navigator.userAgent ;
//ie
if (explorer.indexOf("MSIE") >= 0) {
alert("ie");
}
//firefox
else if (explorer.indexOf("Firefox") >= 0) {
alert("Firefox");
}
//Chrome
else if(explorer.indexOf("Chrome") >= 0){
alert("Chrome");
}
//Opera
else if(explorer.indexOf("Opera") >= 0){
alert("Opera");
}
//Safari
else if(explorer.indexOf("Safari") >= 0){
alert("Safari");
}
}
6.即时时间
<input id="thedatebj" type="text" style="font-size: 9pt; border: 0; width: 75px; background:none; color:#FFF; " readonly="readonly" /> <input id="thetimebj" type="text" style="font-size: 9pt; border: 0; width: 30px; background:none; color:#FFF;" readonly="readonly" />
<script language="javascript" type="text/javascript">
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)clearTimeout(timerID);
timerRunning = false;
}
stopclock();
showtime();
function showtime(){
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var timeValue =hours;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
document.getElementById("thetimebj").value=timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
today=new Date();
function initArray(){
this.length=initArray.arguments.length;
for(var i=0;i<this.length;i++)this[i+1]=initArray.arguments[i];
}
document.getElementById("thedatebj").value=today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate();
</script>