网页跳转代码大全 <一>三种网页跳转代码: 如果你要在服务器端跳转,可以这样: Response.End 如果你要在客户端跳转,可以这样: <script language="javascript" type="text/javascript"> window.location="http: //www.tetou.cn";; </script> 如果你要让页面显示几秒钟之后跳转,可以在html代码的<head></head>部分加上这样的代码: <meta http-equiv="refresh" content="3; url=http://www.tetou.cn"> (3秒钟后自动跳转到www.tetou.cn) 以上三种是也比较常见,比较常用的网页跳转代码运行平台Win9x WinNT Win2000 WinME WinXP。 <二> 几段简单的网页跳转代码 不隐藏转向之后的地址 代码一: <html> <body> <form name=loading> <p align=center><FONT face=Arial color=#0066ff size=2>loading...</FONT> <INPUT style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bolder; PADDING-BOTTOM: 0px; COLOR: #0066ff; BORDER-TOP-style: none; PADDING-TOP: 0px; FONT-FAMILY: Arial; BORDER-RIGHT-style: none; BORDER-LEFT-style: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-style: none" size=46 name=chart> <BR><INPUT style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; COLOR: #0066ff; BORDER-BOTTOM: medium none; TEXT-ALIGN: center" size=47 name=percent> <SCRIPT> var bar=0 var line="||" var amount="||" count() function count(){ bar=bar+2 amount =amount + line document.loading.chart.value=amount document.loading.percent.value=bar+"%" if (bar<99) {setTimeout("count()",100);} else {window.location = "将这里改成要转入的网址";} }</SCRIPT> </P></form> </body> </html> 不隐藏转向之后的地址 代码二: <html> <body> <script language="javascript"> <!-- function goToURL() { //v2.0 for (var i=0; i< (goToURL.arguments.length - 1); i+=2) //with arg pairs eval(goToURL.arguments+".location=''"+goToURL.arguments[i+1]+"''"); document.returnvalue = false; } //--> </script> <body bgcolor="#FFFFFF"> </body> </html> 不隐藏转向之后的地址 代码三: <html> <SCRIPT LANGUAGE="javascript"> <!-- Start Code var ver = navigator.appVersion; if (ver.indexOf("MSIE") != -1) { window.location.href="将这里改成要转入的网址" }else window.location.href="将这里改成要转入的网址" // End Code --> </SCRIPT> </html> 不隐藏转向之后的地址 代码四: <html> <body> <meta http-equiv="refresh" content="0.1;url=将这里改成要转入的网址"> </body> </html> 可隐藏转向之后的地址: <html> <frameset framespacing="0" border="0" rows="0" frameborder="0"> <frame name="main" src="将这里改成要转入的网址" scrolling="auto" noresize> </frameset> </html> <三> 网页跳转 <meta http-equiv="refresh" content="3;rul=跳转的网页"> 此代码可以让网页在一定的时间内,跳转到另外一个网页上,其中content=" 为跳转前停暂的秒数,rul= 为跳转的网址 <meta http-equiv="refresh" content="3;rul=跳转的网页"> 此代码可以让网页在一定的时间内,跳转到另外一个网页上,其中content=" 为跳转前停暂的秒数,rul= 为跳转的网址 =================================================================== <html> <head> <title>网页跳转</title> <meta http-equiv="refresh" content="0;url=cgi-bin/leoboard.cgi"> </head> <body> </body> </html> =================================================================== 1,页面自动刷新:把如下代码加入<head>区域中<meta http-equiv="refresh" content="20">,其中20指每隔20秒刷新一次页面. 2,页面自动跳转:把如下代码加入<head>区域中<meta http-equiv="refresh" content="20;url=http://www.njcatv.net">,其中20指隔20秒后跳转到http://www.njcatv.net页面。 =================================================================== <html> <head> <title>正在进入>>> Loading>>> </title> </head> <body bgcolor="#FFFFFF" text="#000000"> <p> </p><tr> <td width=724> <p align=center><font color="red" size="2">正在进入,请等待,谢谢......</font></p></td></tr><tr> <td width="724"> <p align=center> <form name=loading> <div align=center> <p> <input type=text name=chart size=46 style="font-family:Arial; font-weight:bolder; color:rgb(124,119,119); background-color:white; padding:0px; border-style:none;"> <br> <input type=text name=percent size=46 style="color:rgb(138,134,134); text-align:center; border-width:medium; border-style:none;"><script>var bar = 0 var line = "||" var amount ="||" count() function count(){ bar= bar+2 amount =amount + line document.loading.chart.value=amount document.loading.percent.value=bar+"%" if (bar<99) {setTimeout("count()",10);} else {window.location = "http://www.tetou.cn";} }</script> </body> </html> =================================================================== 如果要cgi的文件,可以用以下方式: #!/usr/bin/perl print "Content-type:text/html "; print<<END; <html> <head> </head> <body bgcolor="#FFFFFF" text="#000000"> <p> </p><tr> <td width=724> <p align=center> </p> !</font></b></p> <p align=center><b><font size="6">正在进入,请等待,谢谢......</font></b></p></td></tr><tr> <td width="724"> <p align=center> <form name=loading> <div align=center> <p> <input type=text name=chart size=46 style="font-family:Arial; font-weight:bolder; color:rgb(124,119,119); background-color:white; padding:0px; border-style:none;"> <br> <input type=text name=percent size=46 style="color:rgb(138,134,134); text-align:center; border-width:medium; border-style:none;" ><script>var bar = 0 var line = "||" var amount ="||" count() function count(){ bar= bar+2 amount =amount + line document.loading.chart.value=amount document.loading.percent.value=bar+"%" if (bar<99) {setTimeout("count()",10);} else {window.location = "http://www.tetou.cn/cgi-bin/leoboard.cgi";} }</script> </body> </html> END exit; =================================================================== 以 htm 可以用以下方式: <html> <body> </body> </html> 以 asp 可以用以下方式: <% response.redirect "http://l39.net/lb5000/leoboard.cgi" %> <四>1. 在<head></head>区域加入 代码: <meta http-equiv=Pragma content=no-cache> <Meta http-equiv="refresh" content="3;url='http://www.tetou.cn' "> 2. JavaScript 代码: <SCRIPT LANGUAGE="JavaScript"> <!-- Begin redirTime = "3000"; redirURL = "http://tetou.cn/"; function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); } // End --> </script> <body> 3. JavaScript 代码: <html><head><title>稍候。。。</title></head> <body> <script language='javascript'>document.location = '跳转地址'</script> </body> </html> 4. 带进度条的页面跳转代码 代码: <html> <head> <meta http-equiv="Content-Language" content="zh-cn"> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"> <title>新视听资源共享论坛</title> </head> <body> <form name=loading> <p align=center><FONT face=Arial color=#0066ff size=2>loading...</FONT> <INPUT style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bolder; PADDING-BOTTOM: 0px; COLOR: #0066ff; BORDER-TOP-style: none; PADDING-TOP: 0px; FONT-FAMILY: Arial; BORDER-RIGHT-style: none; BORDER-LEFT-style: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-style: none" size=46 name=chart> <BR><INPUT style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; COLOR: #0066ff; BORDER-BOTTOM: medium none; TEXT-ALIGN: center" size=47 name=percent> <SCRIPT> var bar=0 var line="||" var amount="||" count() function count(){ bar=bar+2 amount =amount + line document.loading.chart.value=amount document.loading.percent.value=bar+"%" if (bar<99) {setTimeout("count()",100);} else {window.location = "http://www.tetou.cn/";} }</SCRIPT> </P></form> </body> </html> <五> 网页跳转方法+代码 1. window.location <body onload=window.location="http://www.***.com(请换成你的网址)"></body> 或(此法应用范围较广,并可应用在一般后台编辑器中) <script>window.location="http://xxx"</script> 2. META标志 <META HTTP-EQUIV=refresh content="0; url=http://www.***.com(请换成你的网址)"> //其中content后面的阿拉伯数字是代表过几秒中钟转入目标网页。 3. 利用框架隐藏转向地址(此方法不便用 dreamweaver 编辑,请使用记事本或其他文本编辑器处理) <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>知觅__朱高站</title> </head> <frameset rows="*,0" frameborder="no" border="0" framespacing="0"> <frame src="http://www.***.com(请换成你的网址)" name="mainFrame" id="mainFrame"> <frame src="" name="bottomFrame" scrolling="No" noresize="noresize" id="bottomFrame"> </frameset> <noframes> <body> 请用IE浏览 </body> </noframes> </html> <六><html> <head> <title>页面跳转</title> <meta http-equiv="refresh" content="3;url=http://hi.baidu.com/cnredflag"> </head> <body> 此页面三秒后跳转到http://hi.baidu.com/cnredflag </body> </html> <七>html中跳转最全代码 程序代码 <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>正在进入</title> </head> <body> <form name=loading> <p align=center> <font color="#0066ff" size="2">正在进入,请稍等</font><font color="#0066ff" size="2" face="Arial">...</font> <input type=text name=chart size=46 style="font-family:Arial; font-weight:bolder; color:#0066ff; background-color:#fef4d9; padding:0px; border-style:none;"> <input type=text name=percent size=47 style="color:#0066ff; text-align:center; border-width:medium; border-style:none;"> <script> var bar=0 var line="||" var amount="||" count() function count(){ bar=bar+2 amount =amount + line document.loading.chart.value=amount document.loading.percent.value=bar+"%" if (bar<99) {setTimeout("count()",100);} else {window.location = "http://blog.tetou.cn";} }</script> </p> </form> <p align="center"> 如果您的浏览器不支持跳转,<a style="text-decoration: none" href="http://blog.tetou.cn"><font color="#FF0000">请点这里</font></a>.</p> </body> </html> 一个弹出窗口的代码 <SCRIPT LANGUAGE="javascript"> window.open ('http://www.086city.com/ads/index.html', 'newwindow', 'height=400, width=500, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')</SCRIPT> 浮动广告代码 <SCRIPT> var imagepath="http://www.baidu.com/img/logo.gif" //这里是浮动图片的地址 var imagewidth=171 //这两行写图片的大小 var imageheight=133 var speed=3; var imageclick="http://www.SZ800.com/" //这里写点击图片连接到的地址 var hideafter=0 var isie=0; if(window.navigator.appName=="Microsoft Internet Explorer"&&window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE")+5,window.navigator.appVersion.indexOf("MSIE")+8)>=5.5) { isie=1; } else { isie=0; } if(isie){ var preloadit=new Image() preloadit.src=imagepath } function pop() { if(isie) { x=x+dx;y=y+dy; oPopup.show(x, y, imagewidth, imageheight); if(x+imagewidth+5>screen.width) dx=-dx; if(y+imageheight+5>screen.height) dy=-dy; if(x<0) dx=-dx; if(y<0) dy=-dy; startani=setTimeout("pop();",50); } } function dismisspopup(){ clearTimeout(startani) oPopup.hide() } function dowhat(){ if (imageclick=="dismiss") dismisspopup() else window.open(imageclick); } if(isie) { var x=0,y=0,dx=speed,dy=speed; var oPopup = window.createPopup(); var oPopupBody = oPopup.document.body; oPopupBody.style.cursor="hand" oPopupBody.innerHTML = '<IMG SRC="'+preloadit.src+'">'; oPopup.document.body.onmouseover=new Function("clearTimeout(startani)") oPopup.document.body.onmouseout=pop oPopup.document.body.onclick=dowhat pop(); if (hideafter>0) setTimeout("dismisspopup()",hideafter*1000) } </SCRIPT>
网页制作时用到的有用的代码 请问如何去掉主页右面的滚动条? <body scroll="no"> <body style="overflow-y:hidden"> ******************************** 怎样不使用页面的缓存?即每一次打开页面时不是调用缓存中的东西 <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> ******************************** 请问如何忽视右键? <body> ******************************** 怎样在同一页面内控制不同链接的CSS属性? a:active{} a:link{} a:visited{} a.1:active{} a.1:link{} a.1:visited{} 在DW的CSS中定义一个新的标示,按照HTML的语法,超级连接得是 A.YOURS:LINK A.YOURS:HOVER YOURS可以改作你自己的字 然后在选中某个连接后,在CSS面版中点中YOURS即可。 按需要,你可以定义N个标示,N种鼠标OVER的效果 ******************************** 电子邮件处理提交表单 <form name="form1" method="post" action="http://www.pc123.org/html/web/Dreamweaver/200806/mailto:webmail@pc123.org" enctype="text/plain"> <input type=submit> </form> ******************************** 有没有可能用层来遮住FLASH? 1.在flash的parameters里加入 <param name="wmode" value="transparent"> 2.<body onblur=self.focus()> ******************************** 如何根据屏幕分辨率调用相对应的页面? onclick=alert("你的显示分辩率为:"+screen.width+"×"+screen.height) 先做好几个页面,比如一个htm1.htm是800*600,一个是htm2.htm是1024*768的 然后在你的入口页面 index.htm 中判断: <html> <head> <script language=javascript> <!-- function mHref() { if (screen.width == 1024) location.href = "htm2.htm"; else if (screen.width == 800) location.href = "htm1.htm"; else return(false); } //--> </script> </head> <body> </body> </html> ******************************** 如何弹出只有状态栏的窗口? <html> <head> <title>open() close()</title> <script language="javascript" type="text/javascript"> <!-- function openWin() { var newWin=open("","","menubar=1,height=200"); newWin.document.write("<form>"); newWin.document.write("单击以下按钮关闭窗口:<p>"); newWin.document.write("<input type=button value='关闭' onclick=window.close()>"); newWin.document.write("</form>"); } </script></head> <body> <div align=center> <h2>单击以下按钮显示新窗口...</h2> <form name=form1> <input type=button value="新窗口1[只显示地址栏]" onclick=window.open('','new1','location=1')> <input type=button value="新窗口2[只显示状态栏]" onclick=window.open('','','status=1')> <input type=button value="新窗口3[只显示工具栏]" onclick=window.open('','new2','toolbar=1,height=200,width=450')> <input type=button value="新窗口4[只显示菜单栏]" onclick=openWin()> <input type=button value="新窗口5[一个不少]" onclick=window.open('','new5')> <input type=button value="新窗口6[光棍但可调大小]" onclick=window.open('http://www.pc123.org/forumdisplay.php?forumid=32#thread','new6','resizable=1')> </form> </div> </body>
|