常用的ASPJavaScript代码.docx
- 文档编号:9449917
- 上传时间:2023-05-19
- 格式:DOCX
- 页数:13
- 大小:20.46KB
常用的ASPJavaScript代码.docx
《常用的ASPJavaScript代码.docx》由会员分享,可在线阅读,更多相关《常用的ASPJavaScript代码.docx(13页珍藏版)》请在冰点文库上搜索。
常用的ASPJavaScript代码
1.获得系统时间:
<%=now()%>
2.取得来访用的IP:
<%=request.serverVariables("remote_host")%>
3.获得系统,浏览器版本:
window.document.write("版本:
"+navigator.appName+navigator.appVersion+"browser.")
4.去除IE混动条:
hidden"> 5.进入网站,跳出广告: -- --注意更改文件所在路径--> window.open(''http: //www.XXXXXX.com'','''',''height=200,width=300,top=0,left=30''); //--> 6.随机数: <%randomize%> <%=(int(rnd()*n)+1)%> N为可改变数 7.向上混动代码: 9pt;color: #FF0000;line-height: 150%;font-style: italic;font-weight: bold"scrollamount="2"width="206"height="207"bgcolor="#FFFF00">hhhhhhhhhhhhhhhhhhh 8.自动关闭网页: -- setTimeout(''window.close();'',10000);//60秒后关闭 //--> 9.随机背景音乐: <%randomize%> 可以修改数字,限制调用个数,我这里是60个. 10.自动刷新本页面: -- varlimit="0: 10" if(document.images){ varparselimit=limit.split(": ") parselimit=parselimit[0]*60+parselimit[1]*1 } functionbeginrefresh(){ if(! document.images) return if(parselimit==1) window.location.reload() else{ parselimit-=1 curmin=Math.floor(parselimit/60) cursec=parselimit%60 if(curmin! =0) curtime=curmin+"分"+cursec+"秒后重刷本页! " else curtime=cursec+"秒后重刷本页! " window.status=curtime setTimeout("beginrefresh()",1000) } } window.onload=beginrefresh file: //--> 11.用键盘打开网页代码: functionctlent(eventobject) { if((event.ctrlKey&&window.event.keyCode==13)||(event.altKey&&window.event.keyCode==83)) { window.open('网址','','') } } 这里是Ctrl+Enter和Alt+S的代码自己查下键盘的ASCII码再换就行 12.让层不被控件复盖代码: 2>
1>
absolute;top: 40;width: 400px;height: 95px;z-index: 2">
absolute;top: 50;width: 200px;height: 115px;z-index: 1">
13.动网FLASH广告代码:
D27CDB6E-AE6D-11cf-96B8-444553540000"codebase="width="468"height="60"> 14.VBS弹出窗口小代码: msgbox"你还没有注册或登陆论坛","0","精品论坛" location.href="login.asp" 15.文本提交自动分行 text=replace(text,chr(10)," text=replace(text,chr(13)," 16.关闭子窗口时刷新父窗口 在子窗口 window.opener.location="父窗口页面" window.close() 17.关闭子窗口时刷新父窗口 在子窗口代码是: -- self.opener.location.reload(); window.close() --> ----特效字------------------------------------------------------ #000088;FILTER: glow(color=white,strength=1)shadow(color=dddddd,direction=130);LINE-HEIGHT: 23pt;POSITION: relative;WIDTH: 100%">*** ----清空INPUT且选定--------------------------------------------- onClick="Javascript: this.value=''"onFocus="this.select()"onMouseOver="this.focus()" ----全屏显示页面-------------------------------------------- history.back(); chatroom=window.open("chat.asp","chatroom","toolbar=no,status=no,resizable=yes") chatroom.moveTo(0,0); chatroom.resizeTo(screen.availWidth,screen.availHeight); chatroom.outerWidth=screen.availWidth; chatroom.outerHeight=screen.availHeight; ------定时关闭窗口------------------------------------------ vartid=null;tid=setTimeout('window.close()',300000); ------右键屏蔽---------------------------------------------- ------Boom! Boom! 页------------------------------------------ ---------图片重新设置按钮--------------------------------------- functionmyreset() {document.login.reset(); document.login.focus();} hand"onfocus="this.blur()"onclick="myreset()" 1.将彻底屏蔽鼠标右键 oncontextmenu="window.event.returnValue=false" 2.取消选取、防止复制 3.不准粘贴onpaste="returnfalse" 4.防止复制oncopy="returnfalse;"oncut="returnfalse;" 5.IE地址栏前换成自己的图标 6.可以在收藏夹中显示出你的图标 7.关闭输入法 disabled"> 8.永远都会带着框架 -- if(window==top)top.location.href="frames.htm";//frames.htm为框架网页 //--> 9.防止被人frame -- if(top.location! =self.location)top.location=self.location; //--> 10.网页将不能被另存为 11. onclick="window.location='view-source: '+' 12.怎样通过asp的手段来检查来访者是否用了代理 <%ifRequest.ServerVariables("HTTP_X_FORWARDED_FOR")<>""then response.write" "真实的IP为"&Request.ServerVariables("HTTP_X_FORWARDED_FOR") endif %> 13.取得控件的绝对位置 //Javascript functiongetIE(e){ vart=e.offsetTop; varl=e.offsetLeft; while(e=e.offsetParent){ t+=e.offsetTop; l+=e.offsetLeft; } alert("top="+t+"\nleft="+l); } //VBScript -- functiongetIE() dimt,l,a,b seta=document.all.img1 t=document.all.img1.offsetTop l=document.all.img1.offsetLeft whilea.tagName<>"BODY" seta=a.offsetParent t=t+a.offsetTop l=l+a.offsetLeft wend msgbox"top="&t&chr(13)&"left="&l,64,"得到控件的位置" endfunction --> 14.光标是停在文本框文字的最后 functioncc() { vare=event.srcElement; varr=e.createTextRange(); r.moveStart('character',e.value.length); r.collapse(true); r.select(); } 15.判断上一页的来源 asp: request.servervariables("HTTP_REFERER") javascript: document.referrer 16.最小化、最大化、关闭窗口 ADB880A6-D8FF-11CF-9377-00AA003B7A11"> ADB880A6-D8FF-11CF-9377-00AA003B7A11"> adb880a6-d8ff-11cf-9377-00aa003b7a11"> 本例适用于IE 将你的网站设为浏览器的首页 只要在页面适当位置加入如下语句,并将“ 将你的网站添加到收藏夹 window.external.Addfavorite(' 将你的网站添加到频道 首先,你要制作自己的频道文件,然后在网页中加入以下语句,并将“ window.external.addChannel(' 查看上一页/下一页 在页面适当位置加入以下语句,可以进行页面的切换. history.back()">上一页 history.forward()">下一页 定时转向页面 在页面 其中,content="5;中的5为停顿时间(5秒). 窗口的打开/关闭 在页面 varnewWin=***********(",menu=no,resizable=no,width=400,height=300") if(newWin){ setTimeout('newWin.close();',60000) } 其中,('newWin.close();',60000)中的60000为等候时间(60秒),单位为毫秒.若不想自动关闭,请将以下语句删除: if(newWin){ setTimeout('newWin.close();',60000) } 当前窗口的关闭 只要在页面适当位置加入如下语句. window.close()">关闭窗口 在状态栏中显示文字链接的说明 当鼠标指向搜狐这一链接时,在状态栏中将显示“优秀的中文搜索引擎”信息,鼠标移走,状态栏中的信息清空。 取消文字链接的下划线 在页面 当鼠标指向链接时,下划线(红色)才显示(Netscape没有此功能)。 a{text-transform: none;text-decoration: none;} a: hover{text-decoration: underline;color: red;} 保护你的页面不被它人放在框架中 为了保护你的页面,请在页面 if(self! =top){top.location=self.location;} 改变行距 在页面 开头以 P{line-height: 150%} 在页面如下设置: 这是第一行 这是第二行 文本框自动滚动条: 1solid#000000;background-color: white;font-size: 9pt;width: 188;overflow: auto"wrap=hard> 背景全屏 functionmakeIm(){ NS4=(document.layers); IE4=(document.all); scaleWidth=true; scaleHeight=true; imSRC="image/200263164930.jpg"; if(NS4){ origWidth=innerWidth; origHeight=innerHeight;} functionreDo(){ if(innerWidth! =origWidth||innerHeight! =origHeight) location.reload();} if(NS4)onres 如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
")
")no
冰点文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。