補(bǔ)充JS中的特效(常更新)
設(shè)置文本框不允許有焦點(diǎn):
<input type="text" disabled="disabled">
設(shè)置confirm()中的文本內(nèi)容:
confirm("您本次購(gòu)買(mǎi)的商品信息如下:\n商品名稱:跑跑游戲道具;\n商品數(shù)量:5件;\n商品單價(jià):12.5");
\n即代表?yè)Q行
設(shè)置全屏漂浮廣告:
<script language="javascript">
var x = 50,y = 60; //浮動(dòng)廣告初始位置
var xin = true, yin = true; //xin為真,則向右運(yùn)動(dòng),否則向左運(yùn)動(dòng);
var step = 1; //移動(dòng)的距離
var delay = 10;
function floatAD(){
document.body.offsetHeight-document.getElementByIdx_x_x("fly").offsetWidth;
//層移動(dòng)的右邊界
//層移動(dòng)后的上邊界
-1);
L;}
T;}
}
</script>
如何利用JS:
oncontextmenu="window.event.returnValue=false"
將徹底屏蔽鼠標(biāo)右鍵
<body onselectstart="return
false">
取消選取、防止復(fù)制
onpaste="return
false"
不準(zhǔn)粘貼
oncopy="return false;" oncut="return
false;"
防止復(fù)制
-----------------------------------
1.右鍵無(wú)效
view plaincopy to
clipboardprint
<script>
document.oncontextmenu=new
Function("event.returnValue=false;");
</script>
<body>
右鍵無(wú)效
</body>
2.禁止網(wǎng)頁(yè)復(fù)制
view plaincopy to clipboardprint?
<body>
<script
type="text/javascript">
document.body.oncopy=nocopy;
function
nocopy(){
clipboarData.setData("text","");
setTimeout(nocopydelay,100);
}
function
nocopydelay(){
alert("不能復(fù)制");
clipboarData.setData("text","哈哈"+"\r\n文章來(lái)自:sxzlc詳細(xì)參考:"+location.href);
}
</script>
需要使用一下延時(shí)。
強(qiáng)烈建議沒(méi)有什么特殊要求別在自己的網(wǎng)頁(yè)上這么弄。
</body>
3.禁止F5刷新
view plaincopy to
clipboardprint?
<script
type="text/javascript">
document.onkeydown=function()//禁止刷新
{
if(event.keyCode==116){
event.keyCode=0;
event.returnValue=false;
}
}
document.oncontextmenu=function(){
event.returnValue=false;
}
</script>
4.js中的alert的意外發(fā)現(xiàn),以前不知道。
view plaincopy to clipboardprint?
<script
type="text/javascript">
function
sss()
{
alert(sss);
alert('sss');
}
</script>
<body
onload=sss();>
運(yùn)行一下,非常有意思。
第一個(gè),會(huì)把函數(shù)的內(nèi)容顯示出來(lái),對(duì)話框的內(nèi)容是:function
sss(){....}
第二個(gè)輸出才是sss
</body>
5.屏蔽js錯(cuò)誤
<script language="javascript">
<!--
function
killerrors() {
return true;
}
window.onerror =
killerrors;
//-->
</script>
<mec:script
language="javascript">
function
sss(){
alert(sss);
alert('sss');
alert(aaaaa);
}
</script>
<body
onload=sss();>
代碼中注釋去掉與否沒(méi)有影響!
</body>
6.禁用backspace退格鍵
function
document.onkeydown(){
if(event.keyCode==8){
if(document.activeElement.type=="text"){
if(document.activeElement.readOnly==false)
return
true;
}
return false;
}
}
posted on 2012-04-22 15:16 hantai 閱讀(141) 評(píng)論(0) 編輯 收藏