您好,登錄后才能下訂單哦!
這篇文章主要介紹實(shí)用的HTML特效代碼有哪些,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
1。忽視右鍵
<body>
或
<body style="overflow-y:hidden">
2。加入背景音樂(lè)
IE:<bgsound src="" loop=infinite>
NS:<embed src="" autostart=true hidden=true loop=true>
</embed>
*.mid你的背景音樂(lè)的midi格式文件
3。簡(jiǎn)單的window.open方法
<a href=""
>文字或圖片</a>
參數(shù)解釋:
<SCRIPT LANGUAGE="javascript"> js腳本開(kāi)始;
window.open 彈出新窗口的命令;
文件路徑/文件名 彈出窗口的文件名;
newwindow 彈出窗口的名字(不是文件名),非必須,可用空代替;
width=400 窗口寬度;
height=300 窗口高度;
top=0 窗口距離屏幕上方的象素值;
left=0 窗口距離屏幕左側(cè)的象素值;
toolbar=no 是否顯示工具欄,yes為顯示;
menubar,scrollbars 表示菜單欄和滾動(dòng)欄。
resizable=no 是否允許改變窗口大小,yes為允許;
location=no 是否顯示地址欄,yes為允許;
status=no 是否顯示狀態(tài)欄內(nèi)的信息(通常是文件已經(jīng)打開(kāi)),yes為允許;
</SCRIPT> js腳本結(jié)束
4。簡(jiǎn)單的頁(yè)面加密
<script LANGUAGE="javascript">
<!--
function loopy(){
var sWord="";
while(sWord!="login"){sWord=prompt("請(qǐng)輸入你的登陸密碼");}
alert("登陸成功!");
}
loopy()
//-->
</script>
5。拉動(dòng)頁(yè)面時(shí)背景圖不動(dòng)
<style>
body{background-image:url(logo.gif);
background-repeat:no-repeat;background-position:center}
</style>
6。讓瀏覽器在保存頁(yè)面時(shí)保存失敗
<NOSCRIPT><iframe src=""></iframe></NOSCRIPT>
7。隨機(jī)替換圖片
<script>
document.write(<img src="
+.gif"height="40" width="50">
</script>
圖片文件名為0.gif 1.gif 2.gif 3.gif 4.gif
8。窗口定時(shí)關(guān)閉
先將如下代碼網(wǎng)頁(yè)文件的區(qū):
<script language="javascript">
function closeit() { setTimeout("self.close()",10000) //毫秒 }
</script>
然后再在<body>標(biāo)內(nèi)加入如:<body>
9。網(wǎng)頁(yè)自動(dòng)關(guān)閉
<html>
<head>
<object id=closes type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</object>
</head>
<body>
這個(gè)窗口會(huì)在10秒過(guò)后自動(dòng)關(guān)閉,而且不會(huì)出現(xiàn)提示。
</body>
</html>
10。網(wǎng)頁(yè)自動(dòng)刷新
在head部記入
<META HTTP-EQUIV="Refresh" content="20">
其中20為20秒后自動(dòng)刷新,你可以更改為任意值。
11。網(wǎng)頁(yè)自動(dòng)轉(zhuǎn)頁(yè)
<META HTTP-EQUIV="Refresh" CONTENT="時(shí)間(秒);URL=地址">
12。保持layer在最前面,而不被Iframe、Object所覆蓋
在Layer中再插Iframe 或 Object 設(shè)z-Index值
<div z-Index:2><object xxx></object> # 前面
<div z-Index:1><object xxx></object> # 后面
<div id="Layer2" style="position:absolute; top:40;width:400px;
height:95px;z-index:2"> height=100% width=100%>
<iframe width=0 height=0></iframe>
</div>
<div id="Layer1" style="position:absolute; top:50;width:200px;
height:115px;z-index:1">
<iframe height=100% width=100%></iframe>
</div>
13。返回上一頁(yè)
<a href=>『返回上一頁(yè)』</a>
14。關(guān)閉窗口
<a href=>『關(guān)閉窗口』</a>
15。關(guān)于iframe的透明背景
<IFRAME ID="iFrame1" SRC="iframe.htm"
allowTransparency="true"
style="background-color: green"></IFRAME>
16. 徹底屏蔽鼠標(biāo)右鍵
oncontextmenu="window.event.returnValue=false" 將徹底屏蔽鼠標(biāo)右鍵
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
17.取消選取、防止復(fù)制
<body>
18.不準(zhǔn)粘貼
onpaste="return false"
19. 防止復(fù)制
oncopy="return false;"
20. IE地址欄前換成自己的圖標(biāo)
<link rel="Shortcut Icon" href="">
21. 可以在收藏夾中顯示出你的圖標(biāo)
<link rel="Bookmark" href="">
22. 關(guān)閉輸入法
<input style="ime-mode:disabled">
23. 永遠(yuǎn)都會(huì)帶著框架
<script language="JavaScript"><!--
if (window==top)top.location.href=""; //frames.htm為框架網(wǎng)頁(yè)
// --></script>
24. 防止被人frame
<SCRIPT LANGUAGE=JAVASCRIPT><!--
if (top.location !=self.location)top.location=self.location;
// --></SCRIPT>
25. 網(wǎng)頁(yè)將不能被另存為
<noscript><iframe src=></iframe></noscript>
26. 查看網(wǎng)頁(yè)源代碼
<input type=button value=查看網(wǎng)頁(yè)源代碼view-source:"+ """>
27.刪除時(shí)確認(rèn)
<a href=""確實(shí)要?jiǎng)h除嗎?"))location="boos.asp? &areyou=刪除&page=1"">刪除</a>
28.屏蔽功能鍵Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift鍵!"); //可以換成ALT CTRL
}
document.onkeydown=look;
</script>
29. 網(wǎng)頁(yè)不會(huì)被緩存
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">
30.怎樣讓表單沒(méi)有凹凸感?
<input type=text style="border:1 solid #000000">
或
<input type=text style="border-left:none; border-right:none; border
-top:none; border-bottom: 1 solid #000000"></textarea>
31.不要滾動(dòng)條?
讓豎條沒(méi)有:
<body style="overflow:scroll;overflow-y:hidden">
</body>
讓橫條沒(méi)有:
<body style="overflow:scroll;overflow-x:hidden">
</body>
兩個(gè)都去掉?更簡(jiǎn)單了
<body scroll="no">
</body>
32.怎樣去掉圖片鏈接點(diǎn)擊后,圖片周圍的虛線?
<a href=""><img src="" border=0></a>
33.電子郵件處理提交表單
<form name="form1" method="post" action="mailt****@***.com" enctype="text/plain">
<input type=submit>
</form>
34.在打開(kāi)的子窗口刷新父窗口的代碼里如何寫?
window.opener.location.reload()
35.如何設(shè)定打開(kāi)頁(yè)面的大小
<body>
打開(kāi)頁(yè)面的位置<body>
36.在頁(yè)面中如何加入不是滿鋪的背景圖片,拉動(dòng)頁(yè)面時(shí)背景圖不動(dòng)
<STYLE>
body
{background-image:url(logo.gif); background-repeat:no-repeat;
background-position:center;background-attachment: fixed}
</STYLE>
37. 檢查一段字符串是否全由數(shù)字組成
<script language="Javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>
38. 獲得一個(gè)窗口的大小
document.body.clientWidth; document.body.clientHeight
39. 怎么判斷是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有漢字");
else alert("全是字符");
40.TEXTAREA自適應(yīng)文字行數(shù)的多少
<textarea rows=1 name=s1 cols=27>
</textarea>
41. 日期減去天數(shù)等于第二個(gè)日期
<script language=Javascript>
function cc(dd,dadd)
{
//可以加上錯(cuò)誤處理
var a=new Date(dd)
a=a.valueOf()
a=a - dadd * 24 * 60 * 60 * 1000
a=new Date(a)
alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日")
} cc("12/23/2002",2)
</script>
42. 選擇了哪一個(gè)Radio
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
end function
</script><BODY>
<INPUT name="radio1" type="radio" value="style" checked>Style
<INPUT name="radio1" type="radio" value="barcode">Barcode
<INPUT type="button" value="check">
</BODY></HTML>
43.腳本永不出錯(cuò)
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide function killErrors(){return true;} window.onerror=killErrors; // -->
</SCRIPT>
44.ENTER鍵可以讓光標(biāo)移到下一個(gè)輸入框
<input>
45. 檢測(cè)某個(gè)網(wǎng)站的鏈接速度:
把如下代碼加入<body>區(qū)域中:
<script language=Javascript>
tim=1
setInterval("tim++",100)
b=1
var autourl=new Array()
autourl[1]=""
autourl[2]="javacool.3322.net"
autourl[3]=""
autourl[4]=""
autourl[5]=""
function butt(){
document.write("<form name=autof>")
for(var i=1;i<autourl.length;i++)
document.write("<input type=text name=txt"+i+" size=10 value=測(cè)試中
……>=》<input type=text
name=url"+i+" size=40>=》<input type=button value=GO
onclick=window.open(this.form.url"+i+".value)><br>")
document.write("<input type=submit value=刷新></form>")
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="鏈接超時(shí)"}
else
{document.forms[0]["txt"+b].value="時(shí)間"+tim/10+"秒"} b++ }
function
run(){for(var i=1;i<autourl.length;i++)document.write("<img
src=http://"+autourl+"/"+Math.random()+" width=1 height=1
nerror=auto("http://"+autourl+"")>")}
run()</script>
46. 各種樣式的光標(biāo)
auto :標(biāo)準(zhǔn)光標(biāo)
default :標(biāo)準(zhǔn)箭頭
hand :手形光標(biāo)
wait :等待光標(biāo)
text :I形光標(biāo)
vertical-text :水平I形光標(biāo)
no-drop :不可拖動(dòng)光標(biāo)
not-allowed :無(wú)效光標(biāo)
help :?幫助光標(biāo)
all-scroll :三角方向標(biāo)
move :移動(dòng)標(biāo)
crosshair :十字標(biāo)
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize
47、禁止鼠標(biāo)右鍵,把Demo的圖片全都設(shè)為表格的背景,表格的大小與圖片的大小一樣。這樣做看起來(lái)是一樣的,主要是防止鼠標(biāo)經(jīng)過(guò)圖片時(shí)會(huì)出現(xiàn)另存的按鈕。禁止鼠標(biāo)右鍵的代碼很簡(jiǎn)單:
<script LANGUAGE="JavaScript">
function click() { if (event.button==2)
{alert(呵呵,不好意思,你甭想使用右鍵下載圖片:)); } } document.onmousedown=click
</script>
48、在網(wǎng)頁(yè)的Head部分加入如下代碼,這段代碼的主要功能是屏蔽PrintScreen鍵,不斷清空剪貼版,防止圖片被用文件——另存為菜單另存。
<script language="javascript">
<!--
function testclip(){
try {
if(clipboardData.getData("Text")||clipboardData.getData("HTML")||clipboardData.getData("URL"))
{
null;
}
}
catch(e){
clipboardData.setData("Text","")
}
setTimeout("testclip()",500)
}
testclip();
//-->
</script>
以上是“實(shí)用的HTML特效代碼有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。