html常用代码大全( 三 )


28.屏蔽功能键shift、alt、ctrl
脚本
函数look{
if(event.shiftkey)
警报("禁止按变化键!");//可以换成altctrl
}
document.onkeydown=look
/script
29.网页不会被缓存
meta.http-equiv=" pragma" content=" no-cache"
meta.http-equiv="缓存-控制" content="无缓存,必须-重新验证"
meta.http-equiv=" expires" content=" wed,26 feb1997 08:21:57 gmt"
或者meta.http-equiv="expires"content="0 "
30.怎样让表单没有凹凸感?
inputtype=textstyle=" border:1 solid# 000000 "
或inputtype=textstyle=" border-left: none;右边框:无;border-top:无;边框-底部: 1实心# 000000 "/textarea
31.不要滚动条?
让竖条没有:
bodystyle=" overflow:卷轴;溢出-y:隐藏"
/body
让横条没有:
bodystyle=" overflow:卷轴;溢出-x:隐藏"
/body
两个都去掉?更简单了
正文滚动="否"
/body
32.怎样去掉图片链接后,图片周围的虚线?
ahref="http://www.huobaoweishang.com/zhishi/#" nfocus=" this 。blur" imgsrc="http://www.huobaoweishang.com/zhishi/徽标 。jpg"边框=0/a
33.电子邮件处理提交表单
表格name=" form1 " method=" post" action=" mailt* * * * @ * * * .com"enctype="text/plain"
输入类型=提交
/form
34.在打开的子窗口刷新父窗口的代码里如何写?
window.opener.location.reload
35.如何设定打开页面的大小
bodynload="top.resizeto(300,200);"
打开页面的位置bodynload="top.moveby(300,200);"
36.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
风格
身体
{背景图片: url(logo 。gif);背景-重复:不重复;
背景-位置:中心;背景-附件:固定}
/style
37.检查一段字符串是否全由数字组成
剧本language="javascript"!
函数checknum(str){ returnstr 。匹配(//d/)==}
警报(checknum("1232142141 "))
警报(checknum("123214214a1 "))
///脚本
38.获得一个窗口的大小
文件 。尸体 。客户端宽度;document.body.clientheight
39.怎么判断是否是字符
if(/[^/x00-/xff]/g.test(s))警报("含有汉字");
elsealert("全是字符");
40.textarea自适应文字行数的多少
textarearows=1 name=s1 cols=27nppropertychange=" this 。风格 。posheight=this 。滚动高度"
/textarea
41.日期减去天数等于第二个日期
剧本 。语言=javascript
功能cc(dd,dadd)
{
//可以加上错误处理
vara=新日期(日)
a=a.valueof
a=adadd* 24 * 60 * 60 * 1000
新日期
alert(a.getfullyear"年"(a. getmountry^ 1)"月" a.getdate"日")
} cc(" 12/23/2002 ",2)
/script
42.选择了哪一个收音机
html脚本.language="vbscript"
函数checkme
对于无线电一中的每个向船外
如果检查完毕,则window.alertob.value
然后
结束功能
/scriptbody
inputname=" radio1 " type=" radio" value="http://www.huobaoweishang.com/zhishi/style"选中的样式.
输入名称="收音机1 "类型="收音机"值="条形码"条形码
inputtype=" button" value="http://www.huobaoweishang.com/zhishi/check" nclick=" checkme"
/body/html
43.脚本永不出错
脚本.language="javascript"
!隐藏函数killerrors{返回true} window. oneerror=killerrors/
/script
44.进入键可以让光标移到下一个输入框
inputnkeydown=" if(event 。键码==13)事件 。键码=9 "
文末再提两点建议吧:
刚学前端java脚本语言的时候,一定不要追求速成,编程不比其他传统行业,可以快速的上手,他需要一定的代码量积累起来,不然你追求速成很可能会车毁人亡 。
是一家创业点子分享平台,在这里提供互联网创业项目,以及引流推广、网络营