231个常用JavaScript代码

合集下载

73种网页常用js代码

73种网页常用js代码

1、后退前进<input type="button" value="后退" onClick="history.go(-1)"><input type="button" value="前进" onClick="history.go( 1 );return true;">2、返回<form><input type="button" value="返回上一步"onClick="history.back(-1)"></form>3、查看源码<input type="button" name="view" value="查看源码"onClick="window.location="view-source:" +window.location.href">4、禁止查看源码<body oncontextmenu="return false"></body>5、刷新按钮一<input type="button" value="刷新按钮一" onClick="ReloadButton()"><script>function ReloadButton(){location.href="i001.htm";}</script>刷新按钮二<input type="button" value="刷新按钮二" onClick="history.go(0)">6、回首页按钮<input type="button" value="首页" onClick="HomeButton()"><script>functionHomeButton(){location.href=;}</script>7、弹出警告框<input type="button" value="弹出警告框" onClick="AlertButton()"><script>function AlertButton(){window.alert("要多多光临呀!");}</script>8、状态栏信息<input type="button" value="状态栏信息" onClick="StatusButton()"><script>function StatusButton(){window.status="要多多光临呀!";}</script>9、背景色变换<form><input type="button" value="背景色变换"onClick="BgButton()"></form><script>function BgButton(){if (document.bgColor=='#00ffff'){document.bgColor='#ffffff';}else{document.bgColor='#00ffff';}}</script>10、打开新窗口<input type="button" value="打开新窗口" onClick="NewWindow()"><script>functionNewWindow(){window.open("c01.htm","","height=240,width=340,status=no, location=no,toolbar=no,directories=no,menubar=no");}</script>11、窗口最小化<OBJECT id="min" type="application/x-oleobject"classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><PARAMname="Command" value="Minimize"></OBJECT><buttononClick="min.Click()">窗口最小化</button>12、全屏代码<input type="BUTTON" name="FullScreen" value="全屏显示"onClick="window.open(document.location, 'butong_net', 'fullscreen')">13、关闭窗口<OBJECT id=closes type="application/x-oleobject"classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><paramname="Command" value="Close"></object><input type="button" value="关闭窗口" onClick="closes.Click();">关闭窗口<input type=button value=关闭窗口onClick="javascript:self.close()">14、最大化<object id=bigclassid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"><param name="Command" value="Maximize"></object><input type=button value=最大化onClick=big.Click()>15、关闭输入法<input style="ime-mode:disabled" value=关闭输入法>16、链接按钮1<input type="button" value="链接按钮1"onClick="window.open('/', 'Sample','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no ,resizable=yes,copyhistory=yes,width=790,height=520,left=0,top=0')" name="input">链接按钮2<input type="BUTTON" NAME="Button" value="链接按钮2"onClick="showModalDialog('/')">链接按钮3<input type="submit" value="链接按钮3"onClick="location.href='/'">17、警告框显示源代码<BUTTON onClick=alert(document.documentElement.outerHTML)style="width:110">警告框显示源代码</BUTTON>18、点击后按钮清空<input type=button value='打印'onClick="this.style.visibility='hidden';window.print();">19、打印<input type=button value='打印' onClick="window.print();">20、打印预览<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT><input type=button value=打印预览onclick="wb.execwb(7,1)">21、另存为<input onClick="document.execCommand('saveas','true','常用代码.htm')" type=button value=另存为>22、点击自动复制<script>functionoCopy(obj){obj.select();js=obj.createTextRange();js.execCommand("Copy")} </script><input type="text" value="点击自动复制" onClick="oCopy(this)" size="11">23、自动选中<input value="自动选中" onFocus="this.select()" onMouseOver="this.focus()" size="11">24、打开源代码<BUTTON onClick="document.location = 'view-source:' + document.location" size="7">打开源代码</BUTTON>25、新窗口延迟打开<input type=button value=新窗口延迟打开onClick=javascript:setTimeout("window.open('/')",1 0000)>26、实现选中文本框里的前一半的内容<input type="text" value="选中文本框里的前一半的内容" size=30 onmouseover="this.select();tR=document.selection.createRange();tR.moveE nd('character',-8);tR.select();"><input type="text" value="选中部分内容,非IE可以用这个" size=30 onmouseover="this.selectionStart=this.value.length-4;this.selectionEnd=this. value.length">27、点击清空文字<input type="text" name="artist" size=14 value="点击清空文字" onmouseover=this.focus() onfocus=this.select() onclick="if(this.value=='点击清空文字')this.value=''">点击清空文字<input name=name size=11 value=点击清空文字onMouseOver=this.focus() onblur="if (this.value =='') this.value='点击清空文字'" onFocus=this.select() onClick="if (this.value=='点击清空文字') this.value=''">28、等于标题(title):<input type="text" value="" id="aa" size="20"><script>document.getElementById("aa").value=document.title;</script>29、检测IE是否脱机<input type="button" value="测试"onclick="alert(window.navigator.onLine)">30、11种刷新按钮的方法<input type=button value=刷新onClick="history.go(0)"><input type=button value=刷新onClick="location.reload()"><input type=button value=刷新onClick="location=location"><input type=button value=刷新onClick="location.assign(location)"><input type=button value=刷新onClick="document.execCommand('Refresh')"><input type=button value=刷新onClick="window.navigate(location)"><input type=button value=刷新onClick="location.replace(location)"><input type=button value=刷新onClick="window.open('自身的文件','_self')"> <input type=button value=刷新onClick=document.all.WebBrowser.ExecWB(22,1)><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2height=0 id=WebBrowser width=0></OBJECT><form action="自身的文件"><input type=submit value=刷新></form><a id=a1 href="自身的文件"></a><input type=button value=刷新onClick="a1.click()">31、<a href="#" onClick=document.execCommand("open")>打开</a>32、<aonclick="window.open('i001.htm','','height=300,width=300,resizable=no,loca tion=net');" href="">打开指定大小网页</a>33、<a href="#" onClick=location.replace("view-source:"+location)>使用记事本编辑</a>34、<a href="#" onClick=document.execCommand("saveAs")>另存为</a>35、<a href="#" onClick=document.execCommand("print")>打印</a><a href="javascript:window.print();">打印</a>36、<a href=mailto:429752806@>发送E-mail</a>37、<a href="#" onClick=document.execCommand("selectAll")>全选</a>38、<a href="#" onClick=location.reload()>刷新1</a>39、<a href="#" onClick=history.go(0)>刷新2</a>40、<a href="#" onClick=location.replace("view-source:"+location)>查看源文件</a>41、<a href="#" onClick=window.open(document.location,"url","fullscreen")>全屏显示</a>42、<a href="#"onClick=window.external.showBrowserUI("PrivacySettings",null)>internet选项</a>43、<a href="#" oncontextmenu="window.open(this.href);return false;">单击右键将在新窗口中打开</a>44、<a href="#" onClick=history.go(1)>前进1</a><a href="#" onClick=history.forward()>前进2</a><a href="#" onClick=history.go(-1)>后退1</a><a href="#" onClick=history.back()>后退2</a>45、<a href="#"onClick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夹</a><SPAN onClick="window.external.addFavorite('/','网页特效站点')" style="CURSOR: hand" title=网页特效站点>加入收藏</SPAN><a href="#"onClick="window.external.addFavorite('/','网页特效站点')">添加到收藏夹</A><a href="javascript:window.external.AddFavorite('/', '网页特效站点')">点击加入收藏夹</a><a href="#"onmouseover="window.external.addFavorite('/','网页特效站点')" target="_self" >鼠标感应收藏本站</a><a href="#"onmouseover="this.style.behavior='url(#default#homepage)';this.setHomeP age('/js/');" target="_self">鼠标感应设为首页</a>46、<a href="javascript:window.close()">关闭窗口</a><a href="#" onClick=window.close();return false)>关闭窗口</a><a href="#" onClick=setTimeout(window.close(),3000)>3秒关闭本窗口</a><script>function shutwin(){window.close();return;}</script><a href="javascript:shutwin();">关闭本窗口</a>47、<SPAN onClick="varstrHref=window.location.href;this.style.behavior='url(#default#homepage)';t his.setHomePage('/');" style="CURSOR: hand">设为首页</SPAN>48、等于标题栏:<script>document.write(document.title);</script>49、<a href="javascript:void(0);"onClick='window.external.AddFavorite(location.href, document.title);'>收藏本页</a><a href="javascript:window.external.AddFavorite(document.location.href, document.title)">收藏本页</a><a href=javascript:window.external.addChannel("typhoon.cdf")>加入频道</a>50、<a href="i003.htm" onclick="return false;"ondblclick="window.open('i003.htm');">双击打开链接</a>51、<style>#close a:hover{background:url(javascript:window.opener=0;window.close());}</style><div id=close><a href="">关闭窗口</a></div>52、<A HREF="javascript:void(0)" onMouseover="alert('对不起,禁止选中!')">链接禁止</A>53、滚动条在左侧,将<html>改为<HTML DIR="RTL">54、网页半透明<body style="filter:Alpha(Opacity=50)">55、随机选择背景色<body><script>document.body.style.background=(["red","blue","pink","navy","gray","yellow" ,"green","purple"])[parseInt(Math.random()*8)];</script>56、框架页中不显示滚动条:<SCRIPT>self.moveTo(0,0)self.resizeTo(screen.availWidth,screen.availHeight)</SCRIPT>57、防止网页被框架<SCRIPT LANGUAGE=JAVASCRIPT>if (top.location !== self.location) {top.location=self.location;}</SCRIPT>58、永远都会带着框架<script language="javascript"><!--if (window == top)top.location.href = "frame.htm"; //frame.htm为框架网页// --></script>59、窗口自动最大化<script language="JavaScript"><!--self.moveTo(0,0)self.resizeTo(screen.availWidth,screen.availHeight)//--></script>60、打开窗口自动最大化<OBJECT classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT><PARAM name="Command" value="Maximize"></OBJECT>61、爽眼闪屏代码<script>var color = new Array;color[1] = "black";color[2] = "white";for(x = 0; x <3; x++){document.bgColor = color[x];if(x == 2){x = 0;}}</script>62、不能被另存为<noscript><iframe src=*.html></iframe></noscript>63、汉字字库调用<script>for(i=19968;i<40870;i++)document.write(String.fromCharCode(i));</script>64、显示现在时间的脚本<script language=vbscript>document.write now</script>65、显示最后修改时间的脚本<script>document.write(stModified)</script>66、按下F12键,直接返回首页<script>function look(){if(event.keyCode==123){document.location.href=/}}if(document.onkeydown==null){document.onkeydown=look}</script>67、端口检测<img src="http://www.winliuxq/zza.jpg" onload="alert('端口可用')" onerror="alert('端口禁止')"...>68、无法最小化的窗口<body onblur='self.focus();'>69、链接点外部css文件<style>@import url("ie.css");</style>70、内嵌式框架-网页中调用另外网页:<object type="text/x-scriptlet" width="600" height="1000"data="/"></object>71、刷新改变窗口大小<OBJECT classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT><PARAM name="Command" value="Maximize"></OBJECT>72、JavaScript实现网页竖虚线<script>hei=120;d1=2;d2=2;cou=Math.floor(hei/(d1+d2)); document.write('<table cellspacing=0 cellpadding=0 width=1height='+hei+'>');for(i=0;i<cou;i++){document.write('<tr><td height='+d2+'><tr><td height='+d1+' bgcolor=333333>')}</script></table>73、js翻页<script>document.write("<ahref="+location.href.replace(/\.html/g,"_2.html")+">2</a>");</script>。

常用js代码-常用JS代码整理

常用js代码-常用JS代码整理

//檢查時間是否合法(Format: HHMMSS). function validateTime(theStr){ (theStr.length!=6){ (false); } { (theStr \"240000\"){ (true); } var h = theStr.sub(0,2); var m = theStr.sub(2,4); var s = theStr.sub(4,6); (isInt(h)false||isInt(m)false||isInt(s)false){ (false); } (h.length < 2){ (false);} (!isBetween(h,0,23)){ (false);} (!isBetween(m,0,59)){ (false);} (!isBetween(s,0,59)){ (false);} true; } } //檢查str包含漢字時最大長度不大于maxLen function ChineseLenLimit( str, maxLen){ var Strs = str; var strlength=0; var i; for ( i=0;i<str.length;i) { (str.charCodeAt(i)>=1000) strlength 2; strlength 1; } ( strlength > maxLen ){ false; }
} ( isInt( str_f ) false ){ //alert(strMsg); false; } ( isInt( str_b ) false ){ //alert(strMsg); false; } ( dot != dot_last ){ //alert(strMsg); false; } (dot0 || dot_last0){ //alert(strMsg); false; } (str_f.length>i){ //alert(strMsg); false; } (dot!=-1 && str_b.length>j){ //alert(strMsg); false; } true; } //檢查日期格式Format: 99999999) function judgeDateFormat(dateStr){ var re,r; re = /\\d{8}/; r = dateStr.match(re); (r); } //檢查時間格式(Format: 999999)

58项经典的JS代码

58项经典的JS代码
end if
%>
13. 取得控件的绝对位置
//javascript
<script language="javascript">
function getIE(e){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
for each ob in Request.ServerVariables
Response.Write "<TR><TD>"&ob&"</TD><TD>"&Request.ServerVariables(ob)&"</TD></TR>"
Const adOpenStatic = 3 静态游标,只是数据的一个快照,用户对记录说做的修改,增加或删除记录都不会反映到记录集中。支持向前或向后移动
Const adLockReadOnly = 1 锁定类型,默认的,只读,不能作任何修改
Const adLockPessimistic = 2 当编辑时立即锁定记录,最安全的方式
}
cc("12/23/2002",2)
</script>
24. 选择了哪一个Radio
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value

常用JS代码大全

常用JS代码大全

常用JS代码大全事件源对象event.srcElement.tagNameevent.srcElement.type捕获释放event.srcElement.setCapture();event.srcElement.releaseCapture();事件按键event.keyCodeevent.shiftKeyevent.altKeyevent.ctrlKey事件返回值event.returnValue鼠标位置event.xevent.y窗体活动元素document.activeElement绑定事件document.captureEvents(Event.KEYDOWN);访问窗体元素document.all("txt").focus();document.all("txt").select();窗体命令document.execCommand窗体COOKIE document.cookie菜单事件document.oncontextmenu创建元素document.createElement("SPAN");根据鼠标获得元素:document.elementFromPoint(event.x,event.y).tagName=="TD document.elementFromPoint(event.x,event.y).appendChild(ms)窗体图片document.images[索引]窗体事件绑定document.onmousedown=scrollwindow;元素document.窗体.elements[索引]对象绑定事件document.all.xxx.detachEvent('onclick',a);插件数目navigator.plugins取变量类型typeof($js_libpath) == "undefined"下拉框下拉框.options[索引]下拉框.options.length查找对象document.getElementsByName("r1");document.getElementById(id);定时timer=setInterval('scrollwindow()',delay);clearInterval(timer);UNCODE编码escape() ,unescape父对象obj.parentElement(dhtml)obj.parentNode(dom)交换表的行TableID.moveRow(2,1)替换CSS document.all.csss.href = "a.css";并排显示display:inline隐藏焦点hidefocus=true根据宽度换行style="word-break:break-all"自动刷新<meta. HTTP-EQUIV="refresh" C>简单邮件<a href="[email=***********?subject=ccc&body=xxxyyy]mailto:***********?subject=ccc&bod y=xxxyyy[/email]">快速转到位置obj.scrollIntoView(true)锚<a name="first"><a href="#first">anchors</a>网页传递参数location.search();可编辑obj.contenteditable=true执行菜单命令obj.execCommand双字节字符/[^\x00-\xff]/汉字/[\u4e00-\u9fa5]/让英文字符串超出表格宽度自动换行word-wrap: break-word; word-break: break-all;透明背景<IFRAME. src="1.htm" width=300 height=180 allowtransparency></iframe>获得style内容obj.style.cssTextHTML标签document.documentElement.innerHTML第一个style标签document.styleSheets[0]style标签里的第一个样式document.styleSheets[0].rules[0]防止点击空链接时,页面往往重置到页首端。

100句javascript一句话代码(简短常用代码集合,js开发必备的小程序集)

100句javascript一句话代码(简短常用代码集合,js开发必备的小程序集)
31.复选按钮在JS中判断是否选中:document.forms[0].checkThis.checked (checked属性代表为是否选中返回TRUE或FALSE)
32.单选按钮组(单选按钮的名称必须相同):取单选按钮组的长度document.forms[0].groupName.length
70.添加到收藏夹:external.AddFavorite(””,”jaskdlf”);
71.JS中遇到脚本错误时不做任何操作:window.onerror = doNothing; 指定错误句柄的语法为:window.onerror = handleError;
58.innerTEXT的值和上面的一样,只不过不会把< em >这种标记显示出来.
59.contentEditable可设置元素是否可被修改,isContentEditable返回是否可修改的状态.
60.isDisabled判断是否为禁止状态.disabled设置禁止状态
61.length取得长度,返回整型数值
67.取出该元素在页面中出现的数量:document.all.tags(”div(或其它HTML标记符)”).length
68.JS中分为两种窗体输出:模态和非模态.window.showModaldialog(),window.showModeless()
69.状态栏文字的设置:window.status=’文字’,默认的状态栏文字设置:window.defaultStatus = ‘文字.’;
52.JS的内建对象有:Array,Boolean,Date,Error,EvalError,Function,Math,Number,Object,RangeError,ReferenceError,RegExp,String,SyntaxError,TypeError,URIError

一些常用javascript代码

一些常用javascript代码

一些常用javascript代码(转)转自:/yuanyeweber1/blog/item/484df050ea16da858d5430ef.html一些比较简单的javascript:function get_time() /**获取当前时间**/{var date=new Date();var year="",month="",day="",week="",hour="",minute="",second="";year=date.getYear();month=add_zero(date.getMonth()+1);day=add_zero(date.getDate());week=date.getDay();switch (date.getDay()) {case 0:val="星期天";breakcase 1:val="星期一";breakcase 2:val="星期二";breakcase 3:val="星期三";breakcase 4:val="星期四";breakcase 5:val="星期五";breakcase 6:val="星期六";break}hour=add_zero(date.getHours());minute=add_zero(date.getMinutes());second=add_zero(date.getSeconds());timetable.innerText=" "+year+"年"+month+"月"+day+"日"+hour+":"+minute+":"+secon d+" "+val;}1.让文字不停地滚动<MARQUEE>滚动文字</MARQUEE>2.记录并显示网页的最后修改时间<script language=Javascript>document.write("最后更新时间: " + stModified + "")</script>3.关闭当前窗口<a href="/"onClick="javascript:window.close();return false;">关闭窗口</a>4.5秒后关闭当前页<script language="Javascript"><!--setTimeout('window.close();',5000);--></script>5.2秒后载入指定网页<head><meta http-equiv="refresh" content="2;URL=http://你的网址"></head>6.添加到收藏夹<script Language="Javascript">function bookmarkit(){window.external.addFavorite('http://你的网址','你的网站名称')}if (document.all)document.write('<a href="#" onClick="bookmarkit()">加入收藏夹</a>')</script>7.让超链接不显示下划线<style type="text/css"><!-a:link{text-decoration:none}a:hover{text-decoration:none}a:visited{text-decoration:none}-></style>8.禁止鼠标右键的动作<script Language = "Javascript">function click() { if (event.button==2||event.button==3){alert('禁止鼠标右键');}document.onmousedown=click // --></script>9.设置该页为首页<body bgcolor="#FFFFFF" text="#000000"><!-- 网址:http://你的网址--><a class="chlnk" style="cursor:hand" HREFonClick="this.style.behavior='url(#default#homepage)';this.setHomePage('你的网站名称);"><font color="000000" size="2" face="宋体">设为首页</font></a></body>10.节日倒计时<script Language="Javascript">var timedate= new Date("December 25,2003");var times="圣诞节";var now = new Date();var date = timedate.getTime() - now.getTime();var time = Math.floor(date / (1000 * 60 * 60 * 24));if (time >= 0)document.write("现在离"+times+"还有: "+time +"天")</script>11.单击按钮打印出当前页<script Language="Javascript"><!-- Beginif (window.print) {document.write('<form>'+ '<input type=button name=print value="打印本页" '+ 'onClick="javascript:window.print()"></form>');}// End --></script>12.单击按钮‘另存为’当前页<input type="button" name="Button" value="保存本页"onClick="document.all.button.ExecWB(4,1)"><object id="button"width=0height=0classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"><embed width="0" height="0"></embed></object>13.显示系统当前日期<script language=Javascript>today=new Date();function date(){this.length=date.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=date.arguments }var d=new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write("<font color=##000000 style='font-size:9pt;font-family: 宋体'>",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1],"</font>" );</script>14.不同时间段显示不同问候语<script Language="Javascript"><!--var text=""; day = new Date( ); time = day.getHours( );if (( time>=0) && (time <7 ))text="夜猫子,要注意身体哦!"if (( time >= 7 ) && (time <12))text="今天天气……哈哈哈,不去玩吗?"if (( time >= 12) && (time <14))text="午休时间哦,朋友一定是不习惯午睡的吧?!"if (( time >=14) && (time <18))text="下午茶的时间到了,休息一下吧!"if ((time >= 18) && (time <= 22))text="您又来了,可别和MM聊太久哦!"if ((time >= 22) && (time <24))text="很晚了哦,注意休息呀!"document.write(text)//---></script>15.水中倒影效果<img id="reflect" src="你自己的图片文件名" width="175" height="59"><script language="Javascript">function f1(){setInterval("mdiv.filters.wave.phase+=10",100);}if (document.all){document.write('<img id=mdiv src="'+document.all.reflect.src+'"style="filter:wave(strength=3,freq=3,phase=0,lightstrength=30) blur() flipv()">') window.onload=f1}</script>16.慢慢变大的窗口<script Language="Javascript"><!--var Windowsheight=100var Windowswidth=100var numx=5function openwindow(thelocation){temploc=thelocationif(!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getElementById)) {window.open(thelocation)return}windowsize=window.open("","","scrollbars")windowsize.moveTo(0,0)windowsize.resizeTo(100,100)tenumxt()}function tenumxt(){if (Windowsheight>=screen.availHeight-3)numx=0windowsize.resizeBy(5,numx)Windowsheight+=5Windowswidth+=5if (Windowswidth>=screen.width-5){windowsize.location=templocWindowsheight=100Windowswidth=100numx=5return}setTimeout("tenumxt()",50)}//--></script><p><a href="javascript:openwindow(/smile%5F%B1%B4)">进入</a>17.改变IE地址栏的IE图标我们要先做一个16*16的icon(图标文件),保存为index.ico。

常用JS代码大全

常用JS代码大全

常用JS代码大全一、输入框禁止输入中文&lt;input type="text" style="ime-mode:Disabled;"&gt;二、最简单的按钮作为链接方法&lt;INPUT TYPE="submit" value="" onclick="location.href=''"&gt;三、按扭打开Web页对话框&lt;INPUT TYPE="BUTTON" NAME="Button"V ALUE=""onclick="showModalDialog('')"&gt;四、改变IE地址栏的IE图标我们要先做一个16*16的icon(图标文件),保存为index.ico。

把这个图标文件上传到根目录下并在首页<head ></head>之间加上如下代码:&lt;link REL = "Shortcut Icon" href="index.ico"&gt;&lt;link rel="Bookmark" href="favicon.ico"&gt; 可以在收藏夹中显示出你的图标五、让网页随意后退&lt;a href="javascript:history.go(-X)"&gt;X&lt;/a&gt; //把X换成你想要后退在页数//把&#8220;-&#8221;变成&#8220;+&#8221;就为前进六、关闭当前窗口&lt;a href="/"onClick="javascript:window.close();return false;"&gt;关闭窗口&lt;/a&gt;七、2秒后关闭当前页&lt;script language="javascript"&gt;&lt;!--setTimeout('window.close();',2000);--&gt;&lt;/script&gt;八、2秒后载入指定网页&lt;head&gt;&lt;meta http-equiv="refresh" content="2;URL=http://你的网址"&gt;&lt;/head&gt;九、添加到收藏夹&lt;Script Language="javascript"&gt;function bookmarkit(){window.external.addFavorite('http://你的网址','你的网站名称')}if (document.all)document.write('&lt;a href="#" onClick="bookmarkit()"&gt;加入收藏夹&lt;/a&gt;') &lt;/Script&gt;十、设置该页为首页&lt;a class="chlnk" style="cursor:hand" HREFonClick="this.style.behavior='url(#default#homepage)';this.setHomePage('你的网站名称);"&gt;设为首页&lt;/a&gt;十一、单击按钮打印出当前页&lt;Script Language="javascript"&gt;if (window.print) {document.write('&lt;form&gt;'+ '&lt;input type=button name=print value="打印本页" '+'onClick="javascript:window.print()"&gt;&lt;/form&gt;');}&lt;/Script&gt;十二、最小化、最大化、关闭窗口&lt;object id=hh1classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11" &gt;&lt;param name="Command"value="Minimize"&gt;&lt;/object&gt;&lt;object id=hh2classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11" &gt;&lt;param name="Command"value="Maximize"&gt;&lt;/object&gt;&lt;OBJECT id=hh3classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"&gt;&lt;PARAM NAME="Command"V ALUE="Close"&gt;&lt;/OBJECT&gt;&lt;input type=button value=最小化onclick=hh1.Click()&gt;&lt;input type=button value=最大化onclick=hh2.Click()&gt;&lt;input type=button value=关闭onclick=hh3.Click()&gt;本例适用于IE十三、让弹出窗口总是在最上面:&lt;body onblur="this.focus();"&gt;不要滚动条?让竖条没有:&lt;body style='overflow:scroll;overflow-y:hidden'&gt;&lt;/body&gt;让横条没有:&lt;body style='overflow:scroll;overflow-x:hidden'&gt;&lt;/body&gt;两个都去掉?更简单了&lt;body scroll="no"&gt;&lt;/body&gt;十四、电子邮件处理提交表单&lt;form name="form1" method="post"action="mailto:****@***.com" enctype="text/plain"&gt;&lt;input type=submit&gt;&lt;/form&gt;十五、在打开的子窗口刷新父窗口的代码里如何写?window.opener.location.reload()十六、如何设定打开页面的大小&lt;body onload="top.resizeTo(300,200);"&gt;十七、环境变量本机ip&lt;%=request.servervariables("remote_addr")%&gt;服务器名&lt;%=Request.ServerVariables("SERVER_NAME")%&gt;服务器IP&lt;%=Request.ServerVariables("LOCAL_ADDR")%&gt;服务器端口&lt;%=Request.ServerVariables("SERVER_PORT")%&gt;服务器时间&lt;%=now%&gt;IIS版本&lt;%=Request.ServerVariables"SERVER_SOFTWARE")%&gt ;脚本超时时间&lt;%=Server.ScriptTimeout%&gt;本文件路径&lt;%=server.mappath(Request.ServerVariables("SCRIPT_NA ME"))%&gt;服务器CPU数量&lt;%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%&gt;服务器解译引擎&lt;%=ScriptEngine &amp; "/"&amp; ScriptEngineMajorVersion&amp;"."&amp;ScriptEngineMinorVersion&amp;"."&amp; ScriptEngineBuildVersion %&gt;服务器操作系统&lt;%=Request.ServerVariables("OS")%&gt;本篇文章来源于黑客基地-全球最大的中文黑客站原文链接:/tech/2009-09-22/56304_1.html1、后退前进&lt;input type="button" value="后退"onClick="history.go(-1)"&gt;&lt;input type="button" value="前进"onClick="history.go( 1 );return true;"&gt;2、返回&lt;form&gt;&lt;input type="button" value="返回上一步" onClick="history.back(-1)"&gt;&lt;/form&gt;3、查看源码&lt;input type="button" name="view" value="查看源码" onClick="window.location="view-source:"+window.location.href"&gt;4、禁止查看源码&lt;body oncontextmenu="return false"&gt;&lt;/body&gt;5、刷新按钮一&lt;input type="button" value="刷新按钮一"onClick="ReloadButton()"&gt;&lt;script&gt;functionReloadButton(){location.href="i001.htm";}&lt;/script&gt;刷新按钮二&lt;input type="button" value="刷新按钮二"onClick="history.go(0)"&gt;6、回首页按钮&lt;input type="button" value="首页"onClick="HomeButton()"&gt;&lt;script&gt;functionHomeButton(){location.href=;}&lt;/script&gt;7、弹出警告框&lt;input type="button" value="弹出警告框"onClick="AlertButton()"&gt;&lt;script&gt;function AlertButton(){window.alert("要多多光临呀!");}&lt;/script&gt;8、状态栏信息&lt;input type="button" value="状态栏信息"onClick="StatusButton()"&gt;&lt;script&gt;function StatusButton(){window.status="要多多光临呀!";}&lt;/script&gt;9、背景色变换&lt;form&gt;&lt;input type="button" value="背景色变换" onClick="BgButton()"&gt;&lt;/form&gt;&lt;script&gt;function BgButton(){if (document.bgColor=='#00ffff'){document.bgColor='#ffffff';}else{document.bgColor='#00ffff';}}&lt;/script&gt;10、打开新窗口&lt;input type="button" value="打开新窗口"onClick="NewWindow()"&gt;&lt;script&gt;functionNewWindow(){window.open("c01.htm","","height=240,width= 340,status=no,location=no,toolbar=no,directories=no,menubar= no");}&lt;/script&gt;11、窗口最小化&lt;OBJECT id="min" type="application/x-oleobject"classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"&gt;&lt ;PARAM name="Command"value="Minimize"&gt;&lt;/OBJECT&gt;&lt;buttononClick="min.Click()"&gt;窗口最小化&lt;/button&gt;12、全屏代码&lt;input type="BUTTON" name="FullScreen" value="全屏显示" onClick="window.open(document.location, 'butong_net', 'fullscreen')"&gt;13、关闭窗口&lt;OBJECT id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"&gt;&lt ;param name="Command"value="Close"&gt;&lt;/object&gt;&lt;input type="button" value="关闭窗口" onClick="closes.Click();"&gt;关闭窗口&lt;input type=button value=关闭窗口onClick="javascript:self.close()"&gt;14、最大化&lt;object id=bigclassid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11" &gt;&lt;param name="Command"value="Maximize"&gt;&lt;/object&gt;&lt;input type=button value=最大化onClick=big.Click()&gt;15、关闭输入法&lt;input style="ime-mode:disabled" value=关闭输入法&gt;16、链接按钮1&lt;input type="button" value="链接按钮1"onClick="window.open('/', 'Sample', 'toolbar=no,location=no,directories=no,status=no,menubar=no,s crollbars=no,resizable=yes,copyhistory=yes,width=790,height= 520,left=0,top=0')" name="input"&gt;链接按钮2&lt;input type="BUTTON" NAME="Button" value="链接按钮2"onClick="showModalDialog('/')"&gt; 链接按钮3&lt;input type="submit" value="链接按钮3"onClick="location.href='/'"&gt;17、警告框显示源代码&lt;BUTTONonClick=alert(document.documentElement.outerHTML)style="width:110"&gt;警告框显示源代码&lt;/BUTTON&gt;18、点击后按钮清空&lt;input type=button value='打印'onClick="this.style.visibility='hidden';window.print();"&gt;19、打印&lt;input type=button value='打印'onClick="window.print();"&gt;20、打印预览&lt;OBJECTclassid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 " height=0 id=wb name=wb width=0&gt;&lt;/OBJECT&gt;&lt;input type=button value=打印预览onclick="wb.execwb(7,1)"&gt;21、另存为&lt;input onClick="document.execCommand('saveas','true','常用代码.htm')" type=button value=另存为&gt;22、点击自动复制&lt;script&gt;functionoCopy(obj){obj.select();js=obj.createTextRange();js.execCommand("Copy")}&lt;/script&gt;&lt;input type="text" value="点击自动复制"onClick="oCopy(this)" size="11"&gt;23、自动选中&lt;input value="自动选中" onFocus="this.select()" onMouseOver="this.focus()" size="11"&gt;24、打开源代码&lt;BUTTON onClick="document.location = 'view-source:' + document.location" size="7"&gt;打开源代码&lt;/BUTTON&gt;25、新窗口延迟打开&lt;input type=button value=新窗口延迟打开onClick=javascript:setTimeout("window.open('http://www.winli /')",10000)&gt;26、实现选中文本框里的前一半的内容&lt;input type="text" value="选中文本框里的前一半的内容" size=30onmouseover="this.select();tR=document.selection.createRange();tR.moveEnd('character',-8);tR.select();"&gt;&lt;input type="text" value="选中部分内容,非IE可以用这个" size=30onmouseover="this.selectionStart=this.value.length-4;this.select ionEnd=this.value.length"&gt;27、点击清空文字&lt;input type="text" name="artist" size=14 value="点击清空文字" onmouseover=this.focus() onfocus=this.select()onclick="if(this.value=='点击清空文字')this.value=''"&gt;点击清空文字&lt;input name=name size=11 value=点击清空文字onMouseOver=this.focus() onblur="if (this.value =='')this.value='点击清空文字'" onFocus=this.select() onClick="if (this.value=='点击清空文字') this.value=''"&gt;28、等于标题(title):&lt;input type="text" value="" id="aa" size="20"&gt;&lt;script&gt;document.getElementById("aa").value=document .title;&lt;/script&gt;29、检测IE是否脱机&lt;input type="button" value="测试"onclick="alert(window.navigator.onLine)"&gt;30、11种刷新按钮的方法&lt;input type=button value=刷新onClick="history.go(0)"&gt; &lt;input type=button value=刷新onClick="location.reload()"&gt;&lt;input type=button value=刷新onClick="location=location"&gt;&lt;input type=button value=刷新onClick="location.assign(location)"&gt;&lt;input type=button value=刷新onClick="document.execCommand('Refresh')"&gt;&lt;input type=button value=刷新onClick="window.navigate(location)"&gt;&lt;input type=button value=刷新onClick="location.replace(location)"&gt;&lt;input type=button value=刷新onClick="window.open('自身的文件','_self')"&gt;&lt;input type=button value=刷新onClick=document.all.WebBrowser.ExecWB(22,1)&gt;&lt;OBJECTclassid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0&gt;&lt;/OBJECT&gt;&lt;form action="自身的文件"&gt;&lt;input type=submit value=刷新&gt;&lt;/form&gt;&lt;a id=a1 href="自身的文件"&gt;&lt;/a&gt;&lt;inputtype=button value=刷新onClick="a1.click()"&gt;31、&lt;a href="#" onClick=document.execCommand("open")&gt;打开&lt;/a&gt;32、&lt;aonclick="window.open('i001.htm','','height=300,width=300,resiz able=no,location=net');" href=""&gt;打开指定大小网页&lt;/a&gt;33、&lt;a href="#"onClick=location.replace("view-source:"+location)&gt;使用记事本编辑&lt;/a&gt;34、&lt;a href="#" onClick=document.execCommand("saveAs")&gt;另存为&lt;/a&gt;35、&lt;a href="#" onClick=document.execCommand("print")&gt;打印&lt;/a&gt;&lt;a href="javascript:window.print();"&gt;打印&lt;/a&gt;36、&lt;ahref=mailto:*****************&gt;发送E-mail&lt;/a&gt;37、&lt;a href="#"onClick=document.execCommand("selectAll")&gt;全选&lt;/a&gt;38、&lt;a href="#" onClick=location.reload()&gt;刷新1&lt;/a&gt;39、&lt;a href="#" onClick=history.go(0)&gt;刷新2&lt;/a&gt;40、&lt;a href="#"onClick=location.replace("view-source:"+location)&gt;查看源文件&lt;/a&gt;41、&lt;a href="#"onClick=window.open(document.location,"url","fullscreen")&gt;全屏显示&lt;/a&gt;42、&lt;a href="#"onClick=window.external.showBrowserUI("PrivacySettings",nu ll)&gt;internet选项&lt;/a&gt;43、&lt;a href="#" oncontextmenu="window.open(this.href);return false;"&gt;单击右键将在新窗口中打开&lt;/a&gt;44、&lt;a href="#" onClick=history.go(1)&gt;前进1&lt;/a&gt;&lt;a href="#" onClick=history.forward()&gt;前进2&lt;/a&gt; &lt;a href="#" onClick=history.go(-1)&gt;后退1&lt;/a&gt;&lt;a href="#" onClick=history.back()&gt;后退2&lt;/a&gt;45、&lt;a href="#"onClick=window.external.showBrowserUI("OrganizeFavorites", null)&gt;整理收藏夹&lt;/a&gt;&lt;SPANonClick="window.external.addFavorite('http://www.winliuxq.co m/','网页特效站点')" style="CURSOR: hand" title=网页特效站点&gt;加入收藏&lt;/SPAN&gt;&lt;a href="#"onClick="window.external.addFavorite('http://www.winliuxq.co m/','网页特效站点')"&gt;添加到收藏夹&lt;/A&gt;&lt;ahref="javascript:window.external.AddFavorite('http://www.winl /', '网页特效站点')"&gt;点击加入收藏夹&lt;/a&gt;&lt;a href="#"onmouseover="window.external.addFavorite('http://www.winliu /','网页特效站点')" target="_self" &gt;鼠标感应收藏本站&lt;/a&gt;&lt;a href="#"onmouseover="this.style.behavior='url(#default#homepage)';thi s.setHomePage('/js/');" target="_self"&gt;鼠标感应设为首页&lt;/a&gt;46、&lt;a href="javascript:window.close()"&gt;关闭窗口&lt;/a&gt;&lt;a href="#" onClick=window.close();return false)&gt;关闭窗口&lt;/a&gt;&lt;a href="#" onClick=setTimeout(window.close(),3000)&gt;3秒关闭本窗口&lt;/a&gt;&lt;script&gt;function shutwin(){window.close();return;}&lt;/script&gt;&lt;a href="javascript:shutwin();"&gt;关闭本窗口&lt;/a&gt;47、&lt;SPAN onClick="varstrHref=window.location.href;this.style.behavior='url(#default# homepage)';this.setHomePage('/');" style="CURSOR: hand"&gt;设为首页&lt;/SPAN&gt;48、等于标题栏:&lt;script&gt;document.write(document.title);&lt;/script&gt;49、&lt;a href="javascript:void(0);"onClick='window.external.AddFavorite(location.href,document.title);'&gt;收藏本页&lt;/a&gt;&lt;ahref="javascript:window.external.AddFavorite(document.locatio n.href, document.title)"&gt;收藏本页&lt;/a&gt;&lt;ahref=javascript:window.external.addChannel("typhoon.cdf")&gt;加入频道&lt;/a&gt;50、&lt;a href="i003.htm" onclick="return false;"ondblclick="window.open('i003.htm');"&gt;双击打开链接&lt;/a&gt;51、&lt;style&gt;#close a:hover{background:url(javascript:window.opener=0;window.close());} &lt;/style&gt;&lt;div id=close&gt;&lt;a href=""&gt;关闭窗口&lt;/a&gt;&lt;/div&gt;52、&lt;A HREF="javascript:void(0)" onMouseover="alert('对不起,禁止选中!')"&gt;链接禁止&lt;/A&gt;53、滚动条在左侧,将&lt;html&gt;改为&lt;HTMLDIR="RTL"&gt;54、网页半透明&lt;body style="filter:Alpha(Opacity=50)"&gt;55、随机选择背景色&lt;body&gt;&lt;script&gt;document.body.style.background=(["red","blue","pink","navy"," gray","yellow","green","purple"])[parseInt(Math.random()*8)]; &lt;/script&gt;56、框架页中不显示滚动条:&lt;SCRIPT&gt;self.moveTo(0,0)self.resizeTo(screen.availWidth,screen.availHeight)&lt;/SCRIPT&gt;57、防止网页被框架&lt;SCRIPT LANGUAGE=JA V ASCRIPT&gt;if (top.location !== self.location) {top.location=self.location;}&lt;/SCRIPT&gt;58、永远都会带着框架&lt;script language="javascript"&gt;&lt;!--if (window == top)top.location.href = "frame.htm"; //frame.htm 为框架网页// --&gt;&lt;/script&gt;59、窗口自动最大化&lt;script language="JavaScript"&gt;&lt;!--self.moveTo(0,0)self.resizeTo(screen.availWidth,screen.availHeight)//--&gt;&lt;/script&gt;60、打开窗口自动最大化&lt;OBJECTclassid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT&gt;&lt;PARAM name="Command"value="Maximize"&gt;&lt;/OBJECT&gt;&#160;61、爽眼闪屏代码&lt;script&gt;var color = new Array;color[1] = "black";color[2] = "white";for(x = 0; x &lt;3; x++){document.bgColor =color[x];if(x == 2){x = 0;}}&lt;/script&gt;62、不能被另存为&lt;noscript&gt;&lt;iframesrc=*.html&gt;&lt;/iframe&gt;&lt;/noscript&gt;63、汉字字库调用&lt;script&gt;for(i=19968;i&lt;40870;i++)document.write(String.fromCharCo de(i));&lt;/script&gt;64、显示现在时间的脚本&lt;script language=vbscript&gt;document.writenow&lt;/script&gt;65、显示最后修改时间的脚本&lt;script&gt;document.write(stModified)&lt;/scrip t&gt;66、按下F12键,直接返回首页&lt;script&gt;function look(){if(event.keyCode==123){document.location.href=http://www.wi /}}if(document.onkeydown==null){document.onkeydown=look}&lt;/script&gt;67、端口检测&lt;img src="http://www.winliuxq/zza.jpg" onload="alert('端口可用')" onerror="alert('端口禁止')"...&gt;68、无法最小化的窗口&lt;body onblur='self.focus();'&gt;69、链接点外部css文件&lt;style&gt;@import url("ie.css");&lt;/style&gt;70、内嵌式框架-网页中调用另外网页:&lt;object type="text/x-scriptlet" width="600" height="1000" data="/"&gt;&lt;/object&gt;71、刷新改变窗口大小&lt;OBJECTclassid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT&gt;&lt;PARAM name="Command"value="Maximize"&gt;&lt;/OBJECT&gt;72、JavaScript实现网页竖虚线&lt;script&gt;hei=120;d1=2;d2=2;cou=Math.floor(hei/(d1+d2)); document.write('&lt;table cellspacing=0 cellpadding=0 width=1 height='+hei+'&gt;');for(i=0;i&lt;cou;i++){document.write('&lt;tr&gt;&lt;tdheight='+d2+'&gt;&lt;tr&gt;&lt;td height='+d1+'bgcolor=333333&gt;')}&lt;/script&gt;&lt;/table&gt;73、js翻页&lt;script&gt;document.write("&lt;ahref="+location.href.replace(/\.html/g,"_2.html")+"&gt;2&lt;/a &gt;");&lt;/script&gt;。

javascript代码大全

javascript代码大全

目录代码一1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键<table border oncontextmenu=return(false)><td>no</table>可用于Table2. <body onselectstart="return false">取消选取、防止复制3. onpaste="return false" 不准粘贴4. oncopy="return false;" oncut="return false;" 防止复制5. <link rel="Shortcut Icon"href="favicon.ico">IE地址栏前换成自己的图标6. <link rel="Bookmark"href="favicon.ico">可以在收藏夹中显示出你的图标7. <input style="ime-mode:-Disabled">关闭输入法8. 永远都会带着框架<script language="javascript"><!--if(window == top)top.location.href = "frames.htm"; //frames.htm为框架网页// --></script>9. 防止被人frame<SCRIPT LANGUAGE=javascript><!--if(top.location != self.location)top.location=self.location;// --></SCRIPT>10. 网页将不能被另存为<noscript><iframe src=*.html></iframe></noscript>11. <input type=button value=查看网页源代码onclick="window.location = `view-source:`+ /`";>12.删除时确认<a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删除</a>13. 取得控件的绝对位置//javascript<script language="javascript">function getIE(E){var t=e.offsetTop;var l=e.offsetLeft;while(e=e.offsetParent){t+=e.offsetTop;l+=e.offsetLeft;}alert("top="+t+"/nleft="+l);}</script>//VBScript<script language="VBScript"><!--function getIE()dim t,l,a,bset a=document.all.img1t=document.all.img1.offsetTopl=document.all.img1.offsetLeftwhile a.tagName<>"BODY"set a = a.offsetParentt=t+a.offsetTopl=l+a.offsetLeftwendmsgbox"top="&t&chr(13)&"left="&l,64,"得到控件的位置"end function--></script>14. 光标是停在文本框文字的最后<script language="javascript">function cc(){var e = event.srcElement;var r =e.createTextRange();r.moveStart(`character`,e.value.length);r.collapse(true);r.select();}</script><input type=text name=text1 value="123"onfocus="cc()">15. 判断上一页的来源javascript:document.referrer16. 最小化、最大化、关闭窗口<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"><param name="Command"value="Minimize"></object><object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"><param name="Command"value="Maximize"></object><OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><PARAM NAME="Command"value="Close"></OBJECT><input type=button value=最小化onclick=hh1.Click()><input type=button value=最大化onclick=hh2.Click()><input type=button value=关闭onclick=hh3.Click()>本例适用于IE回到目录代码二17.屏蔽功能键Shift,Alt,Ctrl<script>function look(){if(event.shiftKey)alert("禁止按Shift键!"; //可以换成ALT CTRL}document.onkeydown=look;</script>18. 网页不会被缓存<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">19.怎样让表单没有凹凸感?<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>20.<div><span>&<layer>的区别?<div>(division)用来定义大段的页面元素,会产生转行<span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行<layer>是ns的标记,ie不支持,相当于<div>21.让弹出窗口总是在最上面:<body onblur="this.focus();">22.不要滚动条?让竖条没有:<body style=`overflow:-Scroll;overflow-y:hidden`></body>让横条没有:<body style=`overflow:-Scroll;overflow-x:hidden`></body>两个都去掉?更简单了<body scroll="no"></body>23.怎样去掉图片链接点击后,图片周围的虚线?<a href="#"onFocus="this.blur()"><img src="logo.jpg"border=0></a>24.电子邮件处理提交表单<form name="form1"method="post"action="mailto***@***.com"enctype="text/plain"><input type=submit></form>25.在打开的子窗口刷新父窗口的代码里如何写?window.opener.location.reload()26.如何设定打开页面的大小<body onload="top.resizeTo(300,200);">打开页面的位置<body onload="top.moveBy(300,200);">27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动<style>body{background-image:url(logo.gif);background-repeat:no-repeat;background-position:center;background-attachment:fixed}</style>28. 检查一段字符串是否全由数字组成<script language="javascript"><!--function checkNum(str){return str.match(//D/)==null}alert(checkNum("1232142141"alert(checkNum("123214214a1"// --></script>29. 获得一个窗口的大小document.body.clientWidth; document.body.clientHeight30. 怎么判断是否是字符if(/[^/x00-/xff]/g.test(s)) alert("含有汉字";else alert("全是字符";31.TEXTAREA自适应文字行数的多少<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight"> </textarea>32. 日期减去天数等于第二个日期<script language=javascript>function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(A)alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日"}cc("12/23/2002",2)</script>33. 选择了哪一个Radio<HTML><script language="vbscript">function checkme()for each ob in radio1if ob.checked then window.alert ob.valuenextend 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"onclick="checkme()"></BODY></HTML>34.脚本永不出错<SCRIPT LANGUAGE="javascript"><!-- Hidefunction killErrors() {return true;}window.onerror = killErrors;// --></SCRIPT>35.ENTER键可以让光标移到下一个输入框<input onkeydown="if(event.keyCode==13)event.keyCode=9">36. 检测某个网站的链接速度:把如下代码加入<body>区域中:<script language=javascript>tim=1setInterval("tim++",100)b=1var autourl=new Array()autourl[1]="/";autourl[2]=""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=测试中……>=》<input type=textname=url"+i+" size=40> =》<input type=button value=GOonclick=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=urlif(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("<imgsrc=http://"+autourl+"/"+Math.random()+" width=1 height=1onerror=auto(http://";+autourl+"`)>"}run()</script>回到目录代码三37. 各种样式的光标auto :标准光标default :标准箭头hand :手形光标wait :等待光标text :I形光标vertical-text :水平I形光标no-drop :不可拖动光标not-allowed :无效光标help :?帮助光标all-scroll :三角方向标move :移动标crosshair :十字标e-resizen-resizenw-resizew-resizes-resizese-resizesw-resize38.页面进入和退出的特效进入页面<meta http-equiv="Page-Enter"content="revealTrans(duration=x, transition=y)">推出页面<meta http-equiv="Page-Exit"content="revealTrans(duration=x, transition=y)">这个是页面被载入和调出时的一些特效。

js常用代码大全

js常用代码大全

js常⽤代码⼤全Javascript常⽤代码⼤全//打开模式对话框<body><script language=javascript>function doSelectUser(txtId){strFeatures="dialogWidth=500px;dialogHeight=360px;center=yes;middle=yes ;help=no;status=no;scroll=no";var url,strReturn;url="selUser.aspx";strReturn=window.showModalDialog(url,',strFeatures');} doSelectUser()</script></body>//返回模式对话框的值function okbtn_onclick() {var commstr='';window.returnValue=commstr;window.close() ;} okbtn_onclick()//全屏幕打开 IE 窗⼝var winWidth=screen.availWidth ;var winHeight=screen.availHeight-20;window.open("main.aspx","surveyWindow","toolbar=no,width="+ winWidth +",height="+ winHeight +",top=0,left=0,scrollbars=yes,resizable=yes,center:yes,statusbars=yes"); //脚本中中使⽤xmlfunction initialize() {var xmlDocvar xslDocxmlDoc = new ActiveXObject('Microsoft.XMLDOM')xmlDoc.async = false;xslDoc = new ActiveXObject('Microsoft.XMLDOM')xslDoc.async = false;xmlDoc.load("tree.xml")xslDoc.load("tree.xsl")folderTree.innerHTML = xmlDoc.documentElement.transformNode(xslDoc)}⼀、验证类1、数字验证内1.1 整数1.2 ⼤于0的整数(⽤于传来的ID的验证)1.3 负整数的验证1.4 整数不能⼤于iMax1.5 整数不能⼩于iMin2、时间类2.1 短时间,形如 (13:04:06)2.2 短⽇期,形如 (2003-12-05)2.3 长时间,形如 (2003-12-05 13:04:06)2.4 只有年和⽉。

javascript常用代码大全

javascript常用代码大全

javascript常用代码大全非常感谢,本人最近也学习了一个多月的javascript技术,有空也会发表一些文章的。

一、取URL中的参数function getParameterByName(name) {var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);return match && decodeURIComponent(match[1].replace(/\+/g, ' '));}二、正则分组var testStr="<div><img src='/a.jpg' alt='' /><span>test</span><img src='/b.jpg' alt='' /><span>TTest</span><img src='/c.png' alt='' /></div>";var reg=/<img\ssrc='(.*?)'\s+alt=''\s*\/>/g;var match=reg.exec(testStr),results=[];while(match != null){results.push(match[1]);match=reg.exec(testStr);}console.log(results);/*Array ["/a.jpg", "/b.jpg", "/c.png"]*/三、为什么parseInt(1/0,19)的结果为181/0的结果是Infinity,所以parseInt(1/0,19)等同于parseInt("Infinity",19),而在19进制中:19进制 10进制--------------------0 01 12 23 34 45 56 67 78 89 9a 10b 11c 12d 13e 14f 15g 16h 17i 18i表示18,所以parseInt(1/0,19)的结果为18。

javascript常用代码大全-网页设计HTMLCSS

javascript常用代码大全-网页设计HTMLCSS

javas‎c ript‎常用代码‎大全-网页‎设计,HT‎M LCSS‎//打‎开模式对话‎框fu‎n ctio‎n dos‎e lect‎u ser(‎t xtid‎){ ‎‎‎s trfe‎a ture‎s="di‎a logw‎i dth=‎500px‎;dial‎o ghei‎g ht=3‎60px;‎c ente‎r=yes‎;midd‎l e=ye‎s ;he‎l p=n o‎;stat‎u s=no‎;scro‎l l=no‎";‎‎v ar u‎r l,st‎r retu‎r n;‎‎ u‎r l="s‎e luse‎r.asp‎x";‎‎‎‎s trre‎t urn=‎w indo‎w.sho‎w moda‎l dial‎o g(ur‎l,,st‎r feat‎u res)‎;‎}‎//‎返回模式对‎话框的值‎func‎t ion ‎o kbtn‎_oncl‎i ck()‎{‎v ar c‎o mmst‎r=; ‎‎‎‎wind‎o w.re‎t urnv‎a lue=‎c omms‎t r;‎‎ w‎i ndow‎.clos‎e() ;‎}‎全屏幕打开‎ie 窗‎口va‎r win‎w idth‎=scre‎e n.av‎a ilwi‎d th ;‎var‎winh‎e ight‎=scre‎e n.av‎a ilhe‎i ght-‎20;‎w indo‎w.ope‎n("ma‎i n.as‎p x","‎s urve‎y wind‎o w","‎t oolb‎a r=no‎,widt‎h="+ ‎w inwi‎d th ‎+",he‎i ght=‎" + wi‎n heig‎h t +‎",top‎=0,le‎f t=0,‎s crol‎l bars‎=yes,‎r esiz‎a ble=‎y es,c‎e nter‎:yes,‎s tatu‎s bars‎=yes"‎); b‎r eak ‎//脚本‎中中使用x‎m lf‎u ncti‎o n in‎i tial‎i ze()‎{‎var ‎x mldo‎c‎v ar x‎s ldoc‎‎ xml‎d oc =‎new ‎a ctiv‎e xobj‎e ct(m‎i cros‎o ft.x‎m ldom‎)‎x mldo‎c.asy‎n c = ‎f alse‎;‎xs‎l doc ‎= new‎acti‎v exob‎j ect(‎m icro‎s oft.‎x mldo‎m)‎xsld‎o c.as‎y nc =‎fals‎e;‎xm‎l doc.‎l oad(‎"tree‎.xml"‎)‎x sldo‎c.loa‎d("tr‎e e.xs‎l")‎‎fo‎l dert‎r ee.i‎n nerh‎t ml =‎xmld‎o c.do‎c umen‎t elem‎e nt.t‎r ansf‎o rmno‎d e(xs‎l doc)‎}‎一、‎验证类‎1、数字验‎证内‎1.1 ‎整数‎1.2 ‎大于0的整‎数(用于‎传来的id‎的验证) ‎1.‎3负整数‎的验证‎ 1.4‎整数不能‎大于ima‎x‎1.5 整‎数不能小于‎i min ‎2、时间‎类‎2.1 短‎时间,形如‎(13:‎04:06‎)‎2.2 短‎日期,形如‎(200‎3-12-‎05)‎ 2.3‎长时间,‎形如 (2‎003-1‎2-05 ‎13:04‎:06) ‎2.‎4只有年‎和月。

javascript实用代码大全

javascript实用代码大全

javascript实⽤代码⼤全//取得控件得绝对位置(1)<script language="javascript">function getoffset(e){var t=e.offsetTop;var l=e.offsetLeft;while(e=e.offsetParent){t+=e.offsetTop;l+=e.offsetLeft;}var rec = new Array(1);rec[0] = t;rec[1] = l;return rec}</script>//获得控件的绝对位置(2)oRect = obj.getBoundingClientRect();oRect.leftoRect.//最⼩化,最⼤化,关闭<object id=min classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"><param name="Command" value="Minimize"></object><object id=max classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"><param name="Command" value="Maximize"></object><OBJECT id=close classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><PARAM NAME="Command" value="Close"></OBJECT><input type=button value=最⼩化 onclick=min.Click()><input type=button value=最⼤化 onclick=max.Click()><input type=button value=关闭 onclick=close.Click()>//光标停在⽂字最后<script language="javascript">function cc(){var e = event.srcElement;var r =e.createTextRange();r.moveStart('character',e.value.length);r.collapse(true);r.select();}</script><input type=text name=text1 value="123" onfocus="cc()">//页⾯进⼊和退出的特效进⼊页⾯<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">推出页⾯<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">这个是页⾯被载⼊和调出时的⼀些特效。

JS脚本大全各种常用脚本

JS脚本大全各种常用脚本

网页常用小技巧1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键<table border oncontextmenu=return(false)><td>no</table> 可用于Table2. <body onselectstart="return false"> 取消选取、防止复制3. onpaste="return false" 不准粘贴4. oncopy="return false;" oncut="return false;" 防止复制5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标7. <input style="ime-mode:disabled"> 关闭输入法8. 永远都会带着框架<script language="JavaScript"><!--if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页// --></script>9. 防止被人frame<SCRIPT LANGUAGE=JAVASCRIPT><!--if (top.location != self.location)top.location=self.location;// --></SCRIPT>10. 网页将不能被另存为<noscript><iframe src=*.html></iframe></noscript>11. <input type=button value=查看网页源代码onclick="window.location = 'view-source:'+ '/'">12.删除时确认<a href='javascript :if(confirm("确实要删除吗?"))location="boos.asp?& areyou=删除&page=1"'>删除</a>13. 取得控件的绝对位置//Javascript<script language="Javascript">function getIE(e){var t=e.offsetTop;var l=e.offsetLeft;while(e=e.offsetParent){t+=e.offsetTop;l+=e.offsetLeft;}alert("top="+t+"/nleft="+l);}</script>//VBScript<script language="VBScript"><!--function getIE()dim t,l,a,bset a=document.all.img1t=document.all.img1.offsetTopl=document.all.img1.offsetLeftwhile a.tagName<>"BODY"set a = a.offsetParentt=t+a.offsetTopl=l+a.offsetLeftwendmsgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"end function--></script>14. 光标是停在文本框文字的最后<script language="javascript">function cc(){var e = event.srcElement;var r =e.createTextRange();r.moveStart('character',e.value.length);r.collapse(true);r.select();}</script><input type=text name=text1 value="123" onfocus="cc()">15. 判断上一页的来源javascript :document.referrer16. 最小化、最大化、关闭窗口<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> <param name="Command" value="Minimize"></object><object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"><param name="Command" value="Maximize"></object><OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <PARAM NAME="Command" VALUE="Close"></OBJECT><input type=button value=最小化 onclick=hh1.Click()><input type=button value=最大化 onclick=hh2.Click()><input type=button value=关闭 onclick=hh3.Click()>本例适用于IE17.屏蔽功能键Shift,Alt,Ctrl<script>function look(){if(event.shiftKey)alert("禁止按Shift键!"); //可以换成ALT CTRL}document.onkeydown=look;</script>18. 网页不会被缓存<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">19.怎样让表单没有凹凸感?<input type=text style="border:1 solid #000000">或<input type=text style="border-left:none; border-right:none; border-t op:none; border-bottom:1 solid #000000"></textarea>20.<div><span>&<layer>的区别?<div>(division)用来定义大段的页面元素,会产生转行<span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行<layer>是ns的标记,ie不支持,相当于<div>21.让弹出窗口总是在最上面:<body onblur="this.focus();">22.不要滚动条?让竖条没有:<body style='overflow:scroll;overflow-y:hidden'></body>让横条没有:<body style='overflow:scroll;overflow-x:hidden'></body>两个都去掉?更简单了<body scroll="no"></body>23.怎样去掉图片链接点击后,图片周围的虚线?<a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>24.电子邮件处理提交表单<form name="form1" method="post" action="mailto:****@***.com" enctype ="text/plain"><input type=submit></form>25.在打开的子窗口刷新父窗口的代码里如何写?window.opener.location.reload()26.如何设定打开页面的大小<body onload="top.resizeTo(300,200);">打开页面的位置<body onload="top.moveBy(300,200);">27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动<STYLE>body{background-image:url(logo.gif); background-repeat:no-repeat;background-position:center;background-attachment: fixed}</STYLE>28. 检查一段字符串是否全由数字组成<script language="Javascript"><!--function checkNum(str){return str.match(//D/)==null}alert(checkNum("1232142141"))alert(checkNum("123214214a1"))// --></script>29. 获得一个窗口的大小document.body.clientWidth; document.body.clientHeight30. 怎么判断是否是字符if (/[^/x00-/xff]/g.test(s)) alert("含有汉字");else alert("全是字符");31.TEXTAREA自适应文字行数的多少<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeig ht=this.scrollHeight"></textarea>32. 日期减去天数等于第二个日期<script language=Javascript>function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日")}cc("12/23/2002",2)</script>33. 选择了哪一个Radio<HTML><script language="vbscript">function checkme()for each ob in radio1if ob.checked then window.alert ob.valuenextend 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" onclick="checkme()"></BODY></HTML>34.脚本永不出错<SCRIPT LANGUAGE="JavaScript"><!-- Hidefunction killErrors() {return true;}window.onerror = killErrors;// --></SCRIPT>35.ENTER键可以让光标移到下一个输入框<input onkeydown="if(event.keyCode==13)event.keyCode=9">36. 检测某个网站的链接速度:把如下代码加入<body>区域中:<script language=Javascript>tim=1setInterval("tim++",100)b=1var autourl=new Array()autourl[1]=""autourl[2]=""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=测试中……> =》<input type=textname=url"+i+" size=40> =》<input type=button value=GOonclick=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=urlif(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("<imgsrc=http://"+autourl+"/"+Math.random()+" width=1 height=1onerror=auto('http://"+autourl+"')>")}run()</script>37. 各种样式的光标auto :标准光标default :标准箭头hand :手形光标wait :等待光标text :I形光标vertical-text :水平I形光标no-drop :不可拖动光标not-allowed :无效光标help :?帮助光标all-scroll :三角方向标move :移动标crosshair :十字标e-resizen-resizenw-resizew-resizes-resizese-resizesw-resize38.页面进入和退出的特效进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">这个是页面被载入和调出时的一些特效。

javascript常用代码大全(超级收藏,强烈推荐)(4)

javascript常用代码大全(超级收藏,强烈推荐)(4)

javascript常用代码大全(超级收藏,强烈推荐)(4)/*随风JavaScript函数库请把经过测试的函数加入库*//********************函数名称:StrLenthByByte函数功能:计算字符串的字节长度,即英文算一个,中文算两个字节函数参数:str,为需要计算长度的字符串********************/function StrLenthByByte(str){var len;var i;len = 0;for (i=0;i<str.length;i++)< p="">{if (str.charCodeAt(i)>255) len+=2; else len++;}return len;}/********************函数名称:IsEmailAddress函数功能:检查Email邮件地址的合法性,合法返回true,反之,返回false 函数参数:obj,需要检查的Email邮件地址********************/function IsEmailAddress(obj){var pattern=/^[a-zA-Z0-9\\-]+@[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3})$/; if(pattern.test(obj)){return true;}else{return false;}}/********************函数名称:PopWindow函数功能:弹出新窗口函数参数:pageUrl,新窗口地址;WinWidth,窗口的宽;WinHeight,窗口的高********************/function PopWindow(pageUrl,WinWidth,WinHeight){varpopwin=window.open(pageUrl,"PopWin","scrollbars=yes,to olbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width="+Win Width+",height="+WinHei ght);return false;}/********************函数名称:PopRemoteWindow函数功能:弹出可以控制父窗体的原程窗口函数参数:pageUrl,新窗口地址;调用方法:打开窗口:_fcksavedurl=""javascript:popRemoteWindow(url);">Open </str.length;i++)<>。

JS网页常用代码大全

JS网页常用代码大全

onClick="location.href='/'">
17、警告框显示源代码 <BUTTON onClick=alert(document.documentElement.outerHTML) style="width:110">警告框 显
示源代码</BUTTON>
21、另存为 <input onClick="document.execCommand('saveas','true','常用代码.htm')" type=button
value=另存为>
22、点击自动复制 <script>function oCopy(obj){obj.select();js=obj.createTextRange();js.execCommand
点击清空文字 <input name=name size=11 value=点击清空文字 onMouseOver=this.focus() onblur="if
(this.value =='') this.value='点击清空文字'" onFocus=this.select() onClick="if (this.value=='点击清空文字') this.value=''">
JS 网页常用代码大全 ******************************************************************************* ******** 1、后退 前进 <input type="button" value="后退" onClick="history.go(-1)"> <input type="button" value="前进" onClick="history.go( 1 );return true;">

常用的JS代码片段

常用的JS代码片段

常用的JS代码片段判断所有数据类型@param obj 要判断类型的数据@return {string} 数据类型(小写)const type = (function () { // 映射类型const classType = "Boolean Number String Function Array Date RegExp Object Error Null Undefined" .split(" ") .reduce((obj, item) => { obj["[object " + item + "]"] = item.toLowerCase(); return obj; }, {}); return function (obj) { // 仅 undefined 与 null 成立if (obj == null) { return obj + ""; } return typeof obj === "object" ? classType[Object.prototype.toString.call(obj)] : typeof obj; };})();// Examplesconsole.log(type(new Date())); // dateconsole.log(type([1, 2])); // arrayconsole.log(type(1)); // numberconsole.log(type({})); // object判断空对象function isEmptyObject(obj) { if (Object.prototype.toString.call(obj) !== "[object Object]") return false; var name; for (name in obj) { return false; } return true;}// Examplesconsole.log(isEmptyObject({})); // trueconsole.log(isEmptyObject([])); // falseconsole.log(isEmptyObject(null)); // falseconsole.log(isEmptyObject(undefined)); // falseconsole.log(isEmptyObject(1)); // falseconsole.log(isEmptyObject("")); // falseconsole.log(isEmptyObject(true)); // false判断当前运行环境function userAgent() { var u = erAgent; return { // 移动终端浏览器版本信息 trident: u.indexOf("Trident") > -1, // IE内核 presto: u.indexOf("Presto") > -1, // opera内核 webKit:u.indexOf("AppleWebKit") > -1, // 苹果、谷歌内核gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") === -1, // 火狐内核 mobile: !!u.match(/AppleWebKit.*Mobile.*/), // 是否为移动终端iPad: u.indexOf("iPad") > -1, // 是否iPad webApp: u.indexOf("Safari") === -1, // 是否web应该程序,没有头部与底部, isiOS: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), // ios终端isAndroid: u.indexOf("Android") > -1 || u.indexOf("Adr") > -1, };}// Examplesconst browser = userAgent();if (browser.mobile) { // 移动端=> todo something if (browser.isiOS && browser.webApp) { // IOS系统&& web程序=> todo something } else { // 安卓 => todo something }} else { // PC => todo something}平滑滚动到页面顶部const scrollT oTop = () => { const c = document.documentElement.scrollT op || document.body.scrollTop; if (c > 0) { window.requestAnimationFrame(scrollToTop); window.scrollT o(0, c - c / 8); }};// ExamplesscrollToT op();将视口平滑滚动到指定元素const smoothScroll = (element) => document.querySelector(element).scrollIntoView({ behavior: "smooth", });// ExamplessmoothScroll("#fooBar");监听滚动结束const onScrollStop = (callback) => { let isScrolling; window.addEventListener( "scroll", (e) => { clearTimeout(isScrolling); isScrolling = setTimeout(() => { callback(); }, 150); }, false );};// ExamplesonScrollStop(() => { console.log("The user has stopped scrolling");});监听点击指定元素外部const onClickOutside = (element, callback) => { document.addEventListener("click", (e) => { if (!element.contains(e.target)) callback(); });};// ExamplesonClickOutside("#my-element", () => console.log("Hello"));获取浏览器当前语言// defaultLang 为默认语言const detectLanguage = (defaultLang = "en-US") => nguage || (Array.isArray(nguages) && nguages[0]) || defaultLang;// ExamplesdetectLanguage(); // 'nl-NL'控制浏览器全屏、退出全屏const fullscreen = (mode = true, el = "body") => mode ? document.querySelector(el).requestFullscreen() : document.exitFullscreen();// Examplesfullscreen(); // Opens `body` in fullscreen modefullscreen(false); // Exits fullscreen mode封装原生 GET、POST 请求const httpGet = (url, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open("GET", url, true); request.onload = () => callback(request.responseText); request.onerror = () => err(request); request.send();};const httpPost = (url, data, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open("POST", url, true); request.setRequestHeader("Content-type", "application/json; charset=utf-8"); request.onload = () => callback(request.responseText); request.onerror = () => err(request); request.send(data);};// ExampleshttpGet("/posts/1", console.log); /*Logs: { "userId": 1, "id": 1, "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit","body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"}*/httpPost( "/posts", null, // does not send a body console.log); /*Logs: { "id": 101}*/作者:i.faker/post/6990595401657090085。

[小学教育]js经典代码

[小学教育]js经典代码

[1].javascript 判断某页面上的表单数据是否改变过使用场合:当某个页面数据修改时,需要执行某些操作时在页面的body加载事件(onload)中加上initFileds()就可以记录页面的初始数据在需要判断页面数据是否改变时调用checkModification()方法就可判断数据是否改变返回值为true就是已经改变返回值为false就是没有改变// 页面编辑数据var inputsData;var textareasData;var selectsData;// 记录下表单中的原始值function initFileds() {var inputs = document.getElementsByTagName("input");var textareas = document.getElementsByTagName("textarea");var selects = document.getElementsByTagName("select");inputsData = new Array(inputs.length);for (var i=0;i<inputs.length;i++) {inputsData[i] = inputs[i].value;if (inputs[i].type=="radio") {inputsData[i]=inputs[i].checked;}}textareasData = new Array(textareas.length);for (var i=0;i<textareas.length;i++) {textareasData[i] = textareas[i].value;}selectsData = new Array(selects.length);for (var i=0;i<selects.length;i++) {selectsData[i] = selects[i].value;}}/** 判断表单中值是否被修改了* submitCommand 表单有改动时,执行的javascript代码*/function checkModification(submitCommand) {var inputs = document.getElementsByTagName("input");var textareas = document.getElementsByTagName("textarea");var selects = document.getElementsByTagName("select");var hasBeenChanged = false;for (var i=0;i<inputs.length;i++) {if (inputs[i].type=="radio"&&(inputs[i].checked!=inputsData[i])) {hasBeenChanged = true;inputsData[i]=inputs[i].checked;}if (inputs[i].type!="radio"&&inputsData[i]!=inputs[i].value) {if(inputs[i].name!="actionType"){hasBeenChanged = true;}inputsData[i]=inputs[i].value;}}for (var i=0;i<textareas.length;i++) {if (textareasData[i]!=textareas[i].value) {hasBeenChanged = true;textareasData[i]=textareas[i].value;}}for (var i=0;i<selects.length;i++) {if (selectsData[i]!=selects[i].value) {hasBeenChanged = true;selectsData[i]=selects[i].value;}}if (hasBeenChanged&&confirm("数据已经改变,是否保存?")) {eval(submitCommand);}}[2].用javascript检测浏览器是否是遨游(Maxthon)浏览器最近使用一个js的弹出菜单效果,发现在傲游浏览器上对contextmenu事件的执行有些异常。

js练习题代码

js练习题代码

js练习题代码JavaScript (简称JS) 练习题代码以下是一些JS练习题的代码,供您参考。

代码1:```javascript// 1. 将两个数字相加并返回结果function addNumbers(a, b) {return a + b;}// 2. 检查一个数字是否为偶数function isEven(num) {return num % 2 === 0;}// 3. 计算一个数组中所有数字的和function calculateSum(nums) {let sum = 0;for (let i = 0; i < nums.length; i++) {sum += nums[i];}return sum;}// 4. 检查一个字符串是否为回文function isPalindrome(str) {const reversedStr = str.split('').reverse().join(''); return str === reversedStr;}// 5. 打印九九乘法表function printMultiplicationTable() {for (let i = 1; i <= 9; i++) {let row = '';for (let j = 1; j <= i; j++) {row += `${j} * ${i} = ${i * j} `;}console.log(row);}}```代码2:```javascript// 1. 求数组中的最大值function findMaxValue(arr) {let max = arr[0];for (let i = 1; i < arr.length; i++) {if (arr[i] > max) {max = arr[i];}}return max;}// 2. 检查一个字符串是否为有效的邮箱地址function isValidEmail(email) {const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(email);}// 3. 计算一个数字的阶乘function calculateFactorial(num) {let factorial = 1;for (let i = 2; i <= num; i++) {factorial *= i;}return factorial;}// 4. 反转一个字符串function reverseString(str) {return str.split('').reverse().join(''); }// 5. 打印斐波那契数列前 n 个数字function printFibonacciSeries(n) { let fib = [0, 1];for (let i = 2; i < n; i++) {fib[i] = fib[i - 1] + fib[i - 2];}console.log(fib);}```以上是一些简单的JS练习题代码,可以用于巩固和练习JS编程技能。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

event.srcElement.tagNameevent.srcElement.type捕获释放event.srcElement.setCapture();event.srcElement.releaseCapture();事件按键event.keyCodeevent.shiftKeyevent.altKeyevent.ctrlKey事件返回值event.returnValue鼠标位置event.xevent.y窗体活动元素document.activeElement绑定事件document.captureEvents(Event.KEYDOWN);访问窗体元素document.all("txt").focus();document.all("txt").select();窗体命令document.execCommand窗体COOKIEdocument.cookie菜单事件document.oncontextmenu创建元素document.createElement("SPAN");根据鼠标获得元素:document.elementFromPoint(event.x,event.y).tagName=="TD document.elementFromPoint(event.x,event.y).appendChild(ms) 窗体图片document.images[索引]窗体事件绑定document.onmousedown=scrollwindow;元素document.窗体.elements[索引]对象绑定事件document.all.xxx.detachEvent('onclick',a);插件数目navigator.pluginstypeof($js_libpath) == "undefined"下拉框下拉框.options[索引]下拉框.options.length查找对象document.getElementsByName("r1");document.getElementById(id);定时timer=setInterval('scrollwindow()',delay);clearInterval(timer);UNCODE编码escape() ,unescape父对象obj.parentElement(dhtml)obj.parentNode(dom)交换表的行TableID.moveRow(2,1)替换CSSdocument.all.csss.href = "a.css";并排显示display:inline隐藏焦点hidefocus=true根据宽度换行style="word-break:break-all"自动刷新<meta HTTP-EQUIV="refresh" CONTENT="8;URL="> 简单邮件<a href="mailto:aaa@?subject=ccc&body=xxxyyy">快速转到位置obj.scrollIntoView(true)锚<a name="first"><a href="#first">anchors</a>网页传递参数location.search();可编辑obj.contenteditable=true执行菜单命令obj.execCommand双字节字符/[^\x00-\xff]/汉字/[\u4e00-\u9fa5]/让英文字符串超出表格宽度自动换行word-wrap: break-word; word-break: break-all;透明背景<IFRAME src="1.htm" width=300 height=180 allowtransparency></iframe>获得style内容obj.style.cssTextHTML标签document.documentElement.innerHTML第一个style标签document.styleSheets[0]style标签里的第一个样式document.styleSheets[0].rules[0]防止点击空链接时,页面往往重置到页首端。

<a href="BLOCKED SCRIPTfunction()">word</a>上一网页源asp:request.servervariables("HTTP_REFERER")BLOCKED SCRIPTdocument.referrer释放内存CollectGarbage();禁止右键document.oncontextmenu = function() { return false;}禁止保存<noscript><iframe src="*.htm"></iframe></noscript>禁止选取<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"onmouseup="document.selection.empty()>禁止粘贴<input type=text onpaste="return false">地址栏图标<link rel="Shortcut Icon" href="favicon.ico">favicon.ico 名字最好不变16*16的16色,放虚拟目录根目录下收藏栏图标<link rel="Bookmark" href="favicon.ico">查看源码<input type=button value=查看网页源代码onclick="window.location = 'view-source:'+ '/'">关闭输入法<input style="ime-mode:disabled">自动全选<input type=text name=text1 value="123" onfocus="this.select()">ENTER键可以让光标移到下一个输入框<input onkeydown="if(event.keyCode==13)event.keyCode=9">文本框的默认值<input type=text value="123" onfocus="alert(this.defaultValue)">title换行obj.title = "123&#13sdfs&#32"获得时间所代表的微秒var n1 = new Date("2004-10-10".replace(/-/g, "\/")).getTime()窗口是否关闭win.closedcheckbox扁平<input type=checkbox style="position: absolute; clip:rect(5px 15px 15px 5px)"><br>获取选中内容document.selection.createRange().duplicate().text自动完成功能<input type=text autocomplete=on>打开该功能<input type=text autocomplete=off>关闭该功能窗口最大化<body onload="window.resizeTo(window.screen.width - 4,window.screen.height-50);window.moveTo(-4,-4)">无关闭按钮IEwindow.open("aa.htm", "meizz", "fullscreen=7");统一编码/解码alert(decodeURIComponent(encodeURIComponent("http://你好.com?as= hehe"))) encodeURIComponent对":"、"/"、";" 和"?"也编码表格行指示<tr onmouseover="this.bgColor='#f0f0f0'" onmouseout="this.bgColor='#ffffff'">管理员发帖1768•加关注•发消息只看该作者沙发发表于: 2008-08-141.文本框焦点问题onBlur:当失去输入焦点后产生该事件onFocus:当输入获得焦点后,产生该文件Onchange:当文字值改变时,产生该事件Onselect:当文字加亮后,产生该文件<input type="text" value="郭强" onfocus="if(value=='郭强') {value=''}" onblur="if(value=='') {value='郭强'}">点击时文字消失,失去焦点时文字再出现2.网页按钮的特殊颜色<input type=button name="Submit1" value="郭强" size=10 class=s02style="background-color:rgb(235,207,22)">3.鼠标移入移出时颜色变化<input type="submit" value="找吧" name="B1" onMouseOut=this.style.color="blue"onMouseOver=this.style.color="red" class="button">4.平面按钮<input type=submit value=订阅style="border:1px solid :#666666; height:17px; width:25pt; font-size:9pt;BACKGROUND-COLOR: #E8E8FF; color:#666666" name="submit">5.按钮颜色变化<input type=text name="nick" style="border:1px solid #666666; font-size:9pt; height:17px;BACKGROUND-COLOR: #F4F4FF; color:#ff6600" size="15" maxlength="16">6.平面输入框<input type="text" name="T1" size="20" style="border-style: solid; border-width: 1">7.使窗口变成指定的大小<script>window.resizeTo(300,283);</script>8.使文字上下滚动<marquee direction=up scrollamount=1 scrolldelay=100 onmouseover='this.stop()' onmouseout='this.start()'height=60><!-- head_scrolltext --><tr><td>共和国</table> <!-- end head_scrolltext --></marquee>9.状态栏显示该页状态<base onmouseover="window.status='网站建设/' ;return true">10.可以点击文字实现radio选项的选定<br><input type="radio" name="regtype" value="A03" id="A03"><label for="A03"> 情侣: 一次注册两个帐户</label> <br>11.可以在文字域的font写onclick事件12.打印</a>打印网页<a href='javascript:window.print ()'>13.线型输入框<input type="text" name="key" size="12" value="关键字" onFocus=this.select() onMouseOver=this.focus()class="line">14.显示文档最后修改日期<script language=javascript>function hi(str){document.write(stModified)alert("hi"+str+"!")}</script>15.可以在鼠标移到文字上时就触发事件<html><head><script language="LiveScript"><!-- Hidingfunction hello() {alert("哈罗!");}</script></head><body><a href="" onMouseOver="hello()">link</a></body></html>16.可以根据网页上的选项来确定页面颜色<HTML><HEAD><TITLE>background.html</TITLE></HEAD><SCRIPT><!--function bgChange(selObj) {newColor = selObj.options[selObj.selectedIndex].text;document.bgColor = newColor;selObj.selectedIndex = -1;}//--></SCRIPT><BODY STYLE="font-family:Arial"><B>Changing Background Colors</B><BR><FORM><SELECT SIZE="8" onChange="bgChange(this);"><OPTION>Red<OPTION>Orange<OPTION>Yellow<OPTION>Green<OPTION>Blue<OPTION>Indigo<OPTION>Violet<OPTION>White<OPTION>pink</SELECT></FORM></BODY></HTML>17.将按钮的特征改变<style type="text/CSS"><!--.style1 { font-size: 12px; background: #CCCCFF; border-width: thin thin thin thin; border-color: #CCCCFF#CCCCCC #CCCCCC #CCCCFF}.style2 { font-size: 12px; font-weight: bold; background: #CCFFCC; border-width: thin medium medium thin;border-color: #CCFF99 #999999 #999999 #CCFF99}--></style>本例按钮的代码如下:<input type="submit" name="Submit" value="提交" onmouseover="this.className='style2'"onmouseout="this.className='style1'" class="style1">18.改变按钮的图片.<style type="text/css"><!--.style3 { font-size: 12px; background: url(image/buttonbg1.gif); border: 0px; width: 60px; height: 22px}.style4 { font-size: 12px; font-weight: bold; background: url(image/buttonbg2.gif); border: 0px 0; width:60px; height: 22px}--></style>本例的按钮代码如下:<input type="submit" name="Submit2" value="提交" onmouseover="this.className='style4'"onmouseout="this.className='style3'" class="style3">19.打印页面<div align="center"><a class=content href="javascript:doPrint();">打印本稿</a></div>20.可以直接写html语言document.write("");21.改变下拉框的颜色<select name="classid"onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedI ndex].value)"size="1" style="color:#008080;font-size: 9pt">22.转至目标URLwindow.location="http://guoguo"23.传递该object的formUpdateSN('guoqiang99267',this.form)function UpdateSN(strValue,strForm){strForm.SignInName.value = strValue;return false;}24.文字标签<label for="AltName4"><input name="AltName" type="RADIO" tabindex="931" id="AltName4" >guoqiang99859</label>yer2为组件的ID,可以控制组件是否可见document.all.item('Layer2').style.display = "block";document.all.item('Layer2').style.display = "none";//26.将页面加入favorite中<script language=javascript><!--function Addme(){url = "http://your.site.address"; //你自己的主页地址title = "Your Site Name"; //你自己的主页名称window.external.AddFavorite(url,title);--></script>//27.过10秒自动关闭页面< script language="JavaScript" >function closeit() {setTimeout("self.close()",10000)}< /script >28.可以比较字符的大小char=post.charAt(i);if(!('0'<=char&&char<='9'))29.将字符转化为数字month = parseInt(char)30.点击value非空的选项时转向指定连接<select onchange='if(this.value!="")window.open(this.value)' class="textinput"> <option selected>主办单位</option><option>-----------------</option><option value="/">北京日报</option><option value="/">北京晚报</option></select>31.改变背景颜色<td width=* class=dp bgColor=#FAFBFC onmouseover="this.bgColor='#FFFFFF';"onmouseout="this.bgColor='#FAFBFC';">32.改变文字输入框的背景颜色<style>.input2 {background-image: url('../images/inputbg.gif'); font-size: 12px; background-color:#D0DABB;border-top-width:1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}</style><input name=content type=text size="47" class="input2" maxlength="50">33.改变水平线的特征<hr size="0" noshade color="#C0C0C0">34.传递参数的方式<a href="vote.asp?CurPage=8&id=3488">8</a>35.页内跳转<a href="#1">1</a><a href="#2">2</a><a href="#3">3</a><a href="#4">4</a><a href="#5">5</a><a href="#6">6</a><a href="#7">7</a><a name="1">dfdf</a><a name="2">dfdf</a>//36.两个按键一起按下if(event.ctrlKey && window.event.keyCode==13)//37.刷新页面javascript:this.location.reload()//38.将网页的按钮使能<SCRIPT LANGUAGE="JavaScript">function haha(){for(var i=0;i<document.form1.elements.length;i++)if(.indexOf("bb")!=-1)document.form1.elements.disabled=!document.form1.elements.disabled; }}</SCRIPT><BODY><form name=form1><INPUT TYPE="button" NAME="aa " value=cindy onclick=haha()><INPUT TYPE="button" NAME="bb " value=guoguo><INPUT TYPE="button" NAME="bb " value=guoguo>39.文字移动<marquee scrollamount=3 onmouseover=this.stop(); onmouseout=this.start();>40.双击网页自动跑<SCRIPT LANGUAGE="JavaScript">var currentpos,timer;function initialize(){timer=setInterval("scrollwindow()",1);}function sc(){clearInterval(timer);}function scrollwindow(){currentpos=document.body.scrollTop;window.scroll(0,++currentpos);if (currentpos != document.body.scrollTop)sc();}document.onmousedown=scdocument.ondblclick=initialize</SCRIPT>//41.后退<INPUT TYPE="button" onclick=window.history.back() value=back>42.前进<INPUT TYPE="button" onclick=window.history.forward() value=forward>43.刷新<INPUT TYPE="button" onclick=document.location.reload() value=reload>44.转向指定网页document.location="http://ww"或者document.location.assign("")45.在网页上显示实时时间<SCRIPT LANGUAGE="JavaScript">var clock_id;window.onload=function(){clock_id=setInterval("document.form1.txtclock.value=(new Date);",1000)}</SCRIPT>//46.可以下载文件document.location.href="目标文件"//47.连接数据库import java.sql.*;String myDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";Class.forName(myDBDriver);Connection conn=DriverManager.getConnection("jdbc:odbc:firm","username","password"); Statement stmt=conn.createStatement();ResultSet rs=stmt.executeQuery(sql);rs.getString("column1");//48.可以直接在页面“div”内写下所需内容<INPUT TYPE="button" onclick="a1.innerHTML='<font color=red>*</font>'"><div id=a1></div>//49.可以改变页面上的连接的格式,使其为双线<style>A:link {text-decoration: none; color:#0000FF; font-family: 宋体}A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}A:hover {text-decoration: underline overline; color: FF0000}</style><style>A:link {text-decoration: none; color:#0000FF; font-family: 宋体}A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}A:hover {text-decoration: underline overline line-through; color: FF0000}TH{FONT-SIZE: 9pt}TD{FONT-SIZE: 9pt}body {SCROLLBAR-FACE-COLOR: #A9D46D; SCROLLBAR-HIGHLIGHT-COLOR: #e7e7e7;SCROLLBAR-SHADOW-COLOR:#e7e7e7;SCROLLBAR-3DLIGHT-COLOR: #000000; LINE-HEIGHT: 15pt; SCROLLBAR-ARROW-COLOR: #ffffff;SCROLLBAR-TRACK-COLOR: #e7e7e7;}INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE:9pt; BORDER-LEFT-COLOR: #cccccc;BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc;PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc}DIV,form ,OPTION,P,TD,BR{FONT-FAMILY: 宋体; FONT-SIZE: 9pt}textarea, select {border-width: 1; border-color: #000000; background-color: #efefef; font-family: 宋体;font-size: 9pt; font-style: bold;}.text { font-family: "宋体"; font-size: 9pt; color: #003300; border: #006600 solid; border-width: 1px 1px1px 1px}</style>完整的css50.新建frame<ahref="javascript:newframe('/help/a_little/index.html','/help/a_li ttle/a_13.html')"><img alt=帮助border=0 src="/images/mail/button-help.gif"></a>51.向文件中写内容<%@ page import="java.io.*" %><%String str = "print me";//always give the path from root. This way it almost always works.String nameOfTextFile = "/usr/anil/imp.txt";try{PrintWriter pw = new PrintWriter(new FileOutputStream(nameOfTextFile));pw.println(str);//clean uppw.close();}catch(IOException e){out.println(e.getMessage());}%>52.先读文件再写文件<%@ page language = "java" %><%@ page contentType = "text/html; charSet=gb2312" %><%@ page import ="java.util.*" %><%@ page import ="ng.*" %><%@ page import ="javax.servlet.*" %><%@ page import ="javax.servlet.jsp.*" %><%@ page import ="javax.servlet.http.*" %><%@ page import="java.io.*" %>eryrytry<%int count=0;FileInputStream fi =new FileInputStream ("count.txt");ObjectInputStream si= new ObjectInputStream (fi);count =si.readInt();count++;out.print(count);si.close();FileOutputStream fo =new FileOutputStream ("count.txt");ObjectOutputStream so= new ObjectOutputStream (fo);so.writeInt(count);so.close();%>53.直线型输入框<INPUT name=Password size=10 type=password style="border-left-width: 0; border-right-width: 0;border-top-width: 0; border-bottom-style: solid; border-bottom-width: 1; background-color: #9CEB9C">54.可以将背景改为按钮性状,通过改变css改变属性<td width="65" align="center" bgcolor="#E0E0E0" onmouseover=this.className='mouseoverbt';onmouseout=this.className='mouseout';><a href="tm.asp?classid=76"><fontcolor="#000000">录音笔</font></a></td><style>.mouseoverbt{background-image: url( );background-repeat: no-repeat;}.mouseout{background-color: #E0E0E0;}</style>55.同时按下CTRL和Q键document.onkeydown=function(){if(event.ctrlKey&&event.keyCode==81){alert(1)}}//56.以下是一个完整的显示hint的代码,其思想是当鼠标停留是将div中的内容显示在鼠标出,当鼠标移出后在将该div隐藏掉<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><style>#hint{width:198px;border:1px solid #000000;background:#99ff33;position:absolute;z-index:9;padding:6px;line-height:17px;text-align:left;top: 1520px;}</style><SCRIPT LANGUAGE="JavaScript"><!--function showme(){var oSon=window.document.getElementById("hint");if (oSon==null) return;with (oSon){innerText=guoguo.value;style.display="block";style.pixelLeft=window.event.clientX+window.document.body.scrollLeft+6;style.pixelTop=window.event.clientY+window.document.body.scrollTop+9;}}function hidme(){var oSon=window.document.getElementById("hint");if (oSon==null) return;oSon.style.display="none";}//--></SCRIPT><BODY><text id=guoguo value=ga><a href=# onmouseover=showme() onmouseout=hidme() onmousemove=showme() son=hint>dfdfd</a><div id=hint style="display:none"></div></BODY></HTML>---------------------------------------------------------------------------------------------------------------------57.弹出窗口方法一:<body onload="openwen()"> 浏览器读页面时弹出窗口;方法二:<body onunload="openwen()"> 浏览器离开页面时弹出窗口;方法三:用一个连接调用:<a href="#" onclick="openwin()">打开一个窗口</a>注意:使用的"#"是虚连接。

相关文档
最新文档