HTML特效代码⼤全(完整)
1.贴图:<img src="图⽚地址">
2.加⼊连接:<a href="所要连接的相关地址">写上你想写的字</a>
3.在新窗⼝打开连接:<a href="相关地址" target="_blank">写上要写的字</a>
消除连接的下划线在新窗⼝打开连接:
<a href="相关地址" target="_blank">写上你想写的字</a>
4.移动字体(⾛马灯):<marquee>写上你想写的字</marquee>
5.字体加粗:<b>写上你想写的字</b>
6.字体斜体:<i>写上你想写的字</i>
7.字体下划线: <u>写上你想写的字</u>
8.字体删除线: <s>写上你想写的字</s>
9.字体加⼤: <big>写上你想写的字</big>
10.字体控制⼤⼩:<h1>写上你想写的字</h1> (其中字体⼤⼩可从h1-h5,h1最⼤,h5最⼩)
11.更改字体颜⾊:<font color="#value">写上你想写的字</font>(其中value值在000000与ffffff(16位进制)之间
12.消除连接的下划线:<a href="相关地址" >写上你想写的字</a>
13.贴⾳乐:<embed src=⾳乐地址 width=300 height=45 type=audio/mpeg autostart="false">
14.贴flash: <embed src="flash地址" width="宽度" height="⾼度">
15.贴影视⽂件:<img dynsrc="⽂件地址" width="宽度" height="⾼度" start=mouseover>
16.换⾏:<br/>
17.段落:<p>段落</p>
18.原始⽂字样式:<pre>正⽂</pre>
19.换帖⼦背景:<body background="背景图⽚地址">
20.固定帖⼦背景不随滚动条滚动:<body background="背景图⽚地址" body
bgproperties=fixed>
21.定制帖⼦背景颜⾊:<body bgcolor="#value">(value值见10)
22.帖⼦背景⾳乐:<bgsound="背景⾳乐地址" loop=infinite>
23.贴⽹页:<iframe src="相关地址" width="宽度" height="⾼度"></iframe>
HTML特效代码
1。忽视右键
  <body οncοntextmenu="return false">
 或
  <body >
2。加⼊背景⾳乐
  IE:<bgsound src="*.mid" loop=infinite>
  NS:<embed src="*.mid" autostart=true hidden=true loop=true>
  </embed>
  *.mid你的背景⾳乐的midi格式⽂件
3。简单的window.open⽅法
  <a href="#"  οnclick="javascript :window.open(⽂件路径/⽂件名,newwindow,
  toolbar=no,scrollbars=yes,resizable=no,top=0,left=0, width=400,height=300);">⽂字或图⽚</a>
 参数解释:
  <SCRIPT LANGUAGE="javascript"> js脚本开始;
  window.open 弹出新窗⼝的命令;
 ⽂件路径/⽂件名弹出窗⼝的⽂件名;
  newwindow 弹出窗⼝的名字(不是⽂件名),⾮必须,可⽤空代替;
  width=400 窗⼝宽度; height=300 窗⼝⾼度;
  top=0 窗⼝距离屏幕上⽅的象素值; left=0 窗⼝距离屏幕左侧的象素值;
  toolbar=no 是否显⽰⼯具栏,yes为显⽰;
  menubar,scrollbars 表⽰菜单栏和滚动栏。
  resizable=no 是否允许改变窗⼝⼤⼩,yes为允许;
  location=no 是否显⽰地址栏,yes为允许;
  status=no 是否显⽰状态栏内的信息(通常是⽂件已经打开),yes为允许;  </SCRIPT> js脚本结束
4。简单的页⾯加密
  <script LANGUAGE="javascript">
  <!--
  function loopy(){
  var sWord ="";
  while(sWord!="login"){sWord=prompt("请输⼊你的登陆密码");}
  alert("登陆成功!");
  }
  loopy()
  //-->
  </script>
5。拉动页⾯时背景图不动
  <style>
  body{background-image:url(logo.gif);
  background-repeat:no-repeat;background-position:center}
  </style>
6。让浏览器在保存页⾯时保存失败
  <NOSCRIPT><iframe src="*.html"></iframe></NOSCRIPT>
7。随机替换图⽚
  <script>
  document.write(<img src="img/+parseInt(Math.random()*(5))
  +.gif"height="40" width="50">
  </script>
 图⽚⽂件名为0.gif 1.gif 2.gif 3.gif 4.gif
8。窗⼝定时关闭
 先将如下代码⽹页⽂件的区:
  <script language="javascript">
  function closeit() { setTimeout("self.close()",10000) //毫秒 }
  </script>
 然后再在<body>标内加⼊如:<body οnlοad="closeit()">
9。⽹页⾃动关闭
  <html>
  <head>
  <object id=closes type="application/x-oleobject"
  classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
  <param name="Command" value="Close">
  </object>
  </head>
  <body οnlοad="window.setTimeout(closes.Click(),10000)">
 这个窗⼝会在10秒过后⾃动关闭,⽽且不会出现提⽰.
  </body>
  </html>
10。⽹页⾃动刷新
 在head部记⼊
  <META HTTP-EQUIV="Refresh" content="20">
 其中20为20秒后⾃动刷新,你可以更改为任意值。
11。⽹页⾃动转页
  <META HTTP-EQUIV="Refresh" CONTENT="时间(秒);URL=地址"> 12。保持layer在最前⾯,⽽不被Iframe、Object所覆盖
 在Layer中再插Iframe 或 Object 设z-Index值
  <div z-Index:2><object xxx></object> #前⾯
  <div z-Index:1><object xxx></object> #后⾯
  <div id="Layer2" > height=100% width=100%>
  <iframe width=0 height=0></iframe>
  </div>
  <div id="Layer1" >
  <iframe height=100% width=100%></iframe>
  </div>
13。返回上⼀页
  <a href=javascript :history.back(1)>『返回上⼀页』</a>
14。关闭窗⼝
  <a href=javascript :self.close()>『关闭窗⼝』</a>
15。关于iframe的透明背景
  <IFRAME ID="iFrame1" SRC="iframe.htm"
  allowTransparency="true"
  ></IFRAME>
16. οncοntextmenu="urnValue=false" 将彻底屏蔽⿏标右键
<table border οncοntextmenu=return(false)><td>no</table> 可⽤于Table
17. <body onselectstart="return false"> 取消选取、防⽌复制
18.οnpaste="return false" 不准粘贴
19.οncοpy="return false;" oncut="return false;" 防⽌复制
20. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成⾃⼰的图标
21. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显⽰出你的图标
22. <input > 关闭输⼊法
23. 永远都会带着框架
<script language="JavaScript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm为框架⽹页
// --></script>
24. 防⽌被⼈frame
<SCRIPT LANGUAGE=JAVASCRIPT><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
25. ⽹页将不能被另存为
<noscript><iframe src=*.html></iframe></noscript>
26. 查看⽹页源代码
<input type=button value=查看⽹页源代码οnclick="window.location = "view-source:"+ "www.pconline"">
27.删除时确认
<a href="javascript :if(confirm("确实要删除吗?"))location="boos.asp? &areyou=删除&page=1"">删除</a>
28.屏蔽功能键Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁⽌按Shift键!"); //可以换成ALT CTRL
}
document.οnkeydοwn=look;
</script>
29. ⽹页不会被缓存
<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.怎样让表单没有凹凸感?
<input type=text >
或 <input type=text ></textarea> 31.不要滚动条?
让竖条没有:
<body >
</body>
让横条没有:
<body >
</body>
两个都去掉?更简单了
<body scroll="no">
</body>
32.怎样去掉图⽚链接点击后,图⽚周围的虚线?
<a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
33.电⼦邮件处理提交表单
<form name="form1" method="post" action="mailt****@***" enctype="text/plain">
<input type=submit>
</form>
34.在打开的⼦窗⼝刷新⽗窗⼝的代码⾥如何写?
window.load()
35.如何设定打开页⾯的⼤⼩
<body οnlοad="sizeTo(300,200);">
打开页⾯的位置<body οnlοad="veBy(300,200);">
36.在页⾯中如何加⼊不是满铺的背景图⽚,拉动页⾯时背景图不动
<STYLE>
body
{background-image:url(logo.gif); background-repeat:no-repeat;
background-position:center;background-attachment: fixed}
</STYLE>
37. 检查⼀段字符串是否全由数字组成
<script language="Javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>
38. 获得⼀个窗⼝的⼤⼩
document.body.clientWidth; document.body.clientHeight
39. 怎么判断是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有汉字");
else alert("全是字符");
40.TEXTAREA⾃适应⽂字⾏数的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight"> </textarea>
41. ⽇期减去天数等于第⼆个⽇期
<script language=Javascript>
function cc(dd,dadd)
{
//可以加上错误处理
var a = new Date(dd)
a = a.valueOf()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(a)
FullYear() + "年" + (a.getMonth() + 1) + "⽉" + a.getDate() + "⽇")
} cc("12/23/2002",2)
</script>
42. 选择了哪⼀个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" οnclick="checkme()">
</BODY></HTML>
43.脚本永不出错
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide function killErrors(){return true;} r = killErrors; // -->
</SCRIPT>
44.ENTER键可以让光标移到下⼀个输⼊框
<input οnkeydοwn="if(event.keyCode==13)event.keyCode=9">
45. 检测某个⽹站的链接速度:
把如下代码加⼊<body>区域中:
<script language=Javascript>
tim=1
setInterval("tim++",100)
b=1
var autourl=new Array()
autourl[1]="www.njcatv"
autourl[2]="javacool.3322"
autourl[3]="www.sina"
autourl[4]="www.nuaa.edu"
autourl[5]="v"
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=测试中
……> =》<input type=texth5平台源码下载
name=url"+i+" size=40> =》<input type=button value=GO
οnclick=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="链接超时"}
else
{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"} b++ }
function run(){for(var i=1;i<autourl.length;i++)document.write("<img src="+autourl+"/"+Math.random()+" width=1 height=1
nerror=auto(""+autourl+"")>")}
run()</script>
46. 各种样式的光标
auto :标准光标
default :标准箭头
hand :⼿形光标
wait :等待光标
text :I形光标
vertical-text :⽔平I形光标
no-drop :不可拖动光标
not-allowed :⽆效光标
help :?帮助光标
all-scroll :三⾓⽅向标
move :移动标
crosshair :⼗字标
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize
47、禁⽌⿏标右键,把Demo的图⽚全都设为表格的背景,表格的⼤⼩与图⽚的⼤⼩⼀样。这样做看起来是⼀样的,主要是防⽌⿏标经过图⽚时会出现另存的按钮。禁⽌⿏标右键的代码很简单:
<script LANGUAGE="JavaScript">
function click() { if (event.button==2)
{alert(呵呵,不好意思,你甭想使⽤右键下载图⽚:)); } } document.οnmοusedοwn=click
</script>