asp,,
“ASP域名跳转源码
以下是一些常见的ASP域名跳转源码示例:
1、两个域名同一个空间自动跳转的ASP代码:
代码如下:
<% if Request.ServerVariables("SERVER_NAME")="topolo.cn" then response.redirect "default.asp" elseif Request.ServerVariables("SERVER_NAME")="www.qqqzone.net" then response.redirect "default.asp" elseif Request.ServerVariables("SERVER_NAME")="topolo.cn" then response.redirect "cdhome/default.asp" elseif Request.ServerVariables("SERVER_NAME")="www.topolo.cn" then response.redirect "cdhome/default.asp" elseif Request.ServerVariables("SERVER_NAME")="www.qqqzone.net" then response.redirect "blog/" end if %>
解释:通过判断Request.ServerVariables("SERVER_NAME")
的值,根据不同的域名进行相应的页面跳转,如果请求的域名是 “topolo.cn” 或 “www.topolo.cn”,则分别跳转到不同的页面;如果是 “www.qqqzone.net”,则跳转到另一个页面。
2、HTML中跳转最全代码:
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <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 type="text/javascript"> var bar = 0; var line = "||"; var amount = "||"; function count() { bar = bar + 2; document.loading.chart.value = amount; document.loading.percent.value = bar + "%"; if (bar < 99) { setTimeout("count()", 100); } window.location = "http://www.qqqzone.net"; } count(); </script> </p> </form> <p align="center">如果您的浏览器不支持跳转,<a style="text-decoration: none" href="http://www.qqqzone.net"><font color="#FF0000">请点这里</font></a>.</p> </body> </html>
解释:该代码使用JavaScript实现了一个进度条效果,在页面加载时会显示“正在进入,请稍等”,并通过JavaScript控制重定向的时间,当进度条加载完成后会自动跳转到指定网址,还提供了一个链接,如果浏览器不支持跳转,用户可以点击该链接手动跳转。
3、使用Meta标签实现跳转:
代码如下:
<meta http-equiv="Refresh" content="0; URL=index.html">
解释:在HTML文件的<head>
部分添加上述Meta标签,可以设置页面在0秒后自动跳转到指定的URL地址,这是一种简单直接的控制重定向时间的方法。
4、在<body>
里添加代码实现跳转:
代码如下:
<body onload="location.href='http://www.yoururl.com'">
解释:在HTML文件的<body>
标签中使用onload
事件,当页面加载完成时,会自动执行JavaScript代码location.href='http://www.yoururl.com'
,从而实现页面跳转。
5、多域名随机跳转:
代码如下:
<% '定义URL数据 urlData = split("http://www.baidu.com/|http://www.alibaba.com/|http://www.qq.com/|http://www.taobao.com/", "|") '下面都是一样的代码 dim countData() redim countData(0) function getRandomLink(byref selectIndex) if ubound(urlData) <> ubound(countData) then redim countData(ubound(urlData)) end if randomize '(ubound(urlData) + 1)得到总元素数 '保证各个链接几率相同 ' 0-1 ' 1-2 ' 2-3 ' 3-4 selectIndex = rnd() * (ubound(urlData) + 1) '修复进制 ' -0.5-0.5 = 0 ' 0.5-1.5 = 1 ' 1.5-2.5 = 2 ' 2.5-3.5 = 3 selectIndex = cLng(selectIndex 0.5) countData(selectIndex) = countData(selectIndex) + 1 getRandomLink = urlData(selectIndex) end function '测试1000次 do while i < 1000 %><a href="<% =getRandomLink(index) %>">Links_<% =index %></a> <% i = i + 1 loop %><hr /> <% for i = 0 to ubound(countData) %><b>Links_<% =i %>:</b><i><% =countData(i) %></i> <% next %>
解释:通过定义一个包含多个URL的数组urlData
,然后使用getRandomLink
函数随机选择一个URL并返回,每次选择后,都会更新countData
数组来记录每个链接被选中的次数,以保证各个链接被选中的几率相同。
以上内容就是解答有关“asp域名跳转源码”的详细内容了,我相信这篇文章可以为您解决一些疑惑,有任何问题欢迎留言反馈,谢谢阅读。
文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/63776.html<