欢迎来到M1938模板网!
提交工单

常用网页自动跳转实现代码 网页自动跳转代码html

  • 网站教程
  • 编辑:m1938
  • 时间:02/20
  • 阅读:2787

很多站长都会用网页自动跳转来实现一些功能,本文整理五个网页自动跳转的方法来分享给大家,他们都能实现在指定时间后自动跳转到所需要的网页或链接的功能。

第一种:支持定时的html网页跳转
优点:简单
缺点:在Struts Tiles框架中无法使用

<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″>
<!– 以下方式只是3秒后刷新不跳转到其他页面 –>
<meta http-equiv=”refresh” content=”3″>
<!– 以下方式为定时3秒后跳转到其指定页面 –>
<meta http-equiv=”refresh” content=”3;url=https://www.m1938.com/index.php/hongxin/”>
</head>
<body>
//注意:以上两种无法同时使用
</body>
</html>

第二种:支持定时的javascript网页跳转
优点:灵活,可以结合更多的其他功能
缺点:会因浏览器不同而受到影响

<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″>
</head>
<body>
<script language=”javascript” type=”text/javascript”>
// 以下方式直接跳转
window.location.href=’https://www.m1938.com/index.php/hongxin/’;
// 以下方式定时跳转
setTimeout(“javascript:location.href=’https://www.m1938.com/index.php/hongxin/'”, 5000);
</script>

//注意:以上两种无法同时使用
</body>
</html>

第三种:javascript实现简单的网页跳转
优点:简单,快速
缺点:可制定性不强

<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″>
</head>
<body>
<script language=’javascript’>document.location = ‘https://www.m1938.com/index.php/hongxin/'</script>
</body>
</html>

第四种:结合了倒数功能的javascript网页跳转
优点:更人性化
缺点:不支持span、div等 innerText属性的浏览器无法使用。

<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″>
</head>
<body>
<span id=”totalSecond”>3</span>秒后自动跳转
<script language=”javascript” type=”text/javascript”>
var second = document.getElementById(‘totalSecond’).textContent;

if (navigator.appName.indexOf(“Explorer”) > -1) {
second = document.getElementById(‘totalSecond’).innerText;
} else {
second = document.getElementById(‘totalSecond’).textContent;
}

setInterval(“redirect()”, 1000);
function redirect() {
if (second < 0) {
location.href = ‘https://www.m1938.com/index.php/hongxin/’;
} else {
if (navigator.appName.indexOf(“Explorer”) > -1) {
document.getElementById(‘totalSecond’).innerText = second–;
} else {
document.getElementById(‘totalSecond’).textContent = second–;
}
}
}
</script>
</body>
</html>

第五种:经过简单美化的javascript网页跳转
优点:功能更全面,美观
缺点:一些浏览器可能需要手动点击跳转

<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″>
<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 = “https://www.m1938.com/index.php/hongxin/”;}
}</script>
</p>
</form>
<p align=”center”> 如果您的浏览器不支持跳转,<a style=”text-decoration: none” href=”https://www.m1938.com/page/15.html”><font color=”#FF0000″>请点这里</font></a>.</p>
</body>
</html>


方案一

<html>
<head>
<meta http-equiv="Content-Language" content="zh-CN">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<meta http-equiv="refresh" content="0.1;url=https://www.m1938.com">
<title></title>
</head>
<body>
</body>
</html>

方案二

<html>
<head>

<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 = "https://www.m1938.com";} 
}</script>
 </p>
</form>
<p align="center"> 如果您的浏览器不支持跳转,<a style="text-decoration: none" href="https://www.m1938.com"><font color="#FF0000">请点这里</font></a>.</p>
</body>
</html>

 


全部评论(0)
推荐教程
  • 马克斯CMS模板播放列表错位解决方法
  • 马克斯CMS模板播放列表错位解决方法
  • 马克斯CMS模板播放列表错位解决方法发现用马克斯CMS模板的朋友很多出现播放列表错位无法解决现在分享一下解决方法,希望能帮到你.inc\CommonFun.asp查找以下段落中和去掉,重新生成case
  • 马克斯max教程
  • 编辑:m1938
  • 时间:02/20
  • 阅读:2011
  • 飞飞cms影视系统3.0程序最新官方正式版下载
  • 飞飞cms影视系统3.0程序最新官方正式版下载
  • 程序名称:飞飞影视导航系统程序版本:3.0150416发布日期:2015-04-16安装环境:php5或更高版本、mysql5或更高版本--------------------------------------- 飞飞影视导航系统安装说明---------------------------------------1. 
  • 飞飞cms教程
  • 编辑:m1938
  • 时间:02/20
  • 阅读:2953
  • 苹果CMS10影视程序自动采集教程
  • 苹果CMS10影视程序自动采集教程
  • 在建立好自己的网站添加自定义资源库后,由于手动采集方式比较耗时间和精力更新也不够及时,是不是特别希望能有一个全自动定时采集方法来帮助网站增加视频资源解放自己的双手,m1938现在就教大家如何用宝塔一步一步实现这个定时采集任务。1.进入苹果CMS10后台,点击–采集2.在采集页面,点击左侧“自定义资源库,鼠标右键点击需要采集的内容,如“采集当天”、“采集本周””采集所有“,选择复制链接地址。  &nb
  • 苹果cmsv10教程
  • 来源:m1938
  • 编辑:m1938
  • 时间:02/20
  • 阅读:17111
  • 苹果CMSV10程序被经常挂木马跳转彻底解决办法
  • 苹果CMSV10程序被经常挂木马跳转彻底解决办法
  • 苹果V10的程序一直被挂木马,彻底解决办法如下把程序版本一定要升级到最新版本最新程序版本可以在这里下载https://www.m1938.com/maccms/如果更新了最新版本还是被挂木马那就只有按下面的方法彻底解决首先登录苹果cmsv10的网站后台把分类全
  • 苹果cmsv10教程
  • 时间:02/20
  • 阅读:9448
本站声明 请在遵守中华人民共和国法律法规的情况下使用本站模板,严禁将M1938模板网的模板用在涉黄、涉黑、涉赌、涉毒、涉电信诈骗等任何涉嫌违法活动站点,本站所有代码模板仅供学习交流使用,请勿用于商业用途,及违法侵权行为使用均与本站无关!
网站首页  |   关于我们  |   广告合作  |   联系我们  |   隐私条款  |   免责声明  |   网站地图
CopyRight 2026 M1938模板网