Page Redirect Speed Test

现在,有两种方法可以实现网页的自动跳转。

(1) 用html自带的<meta>标签(如下)可以实现网页的自动跳转,而且可以控制跳转的延时。

<meta http-equiv="Refresh" content="0;url=http://www.baidu.com">
其中,数字0代表延时尽可能小。

(2) Java Script中的window.location语句也可以实现page redirect。

window.location="http://www.baidu.com";

下面写两个简单的网页,来测试下这两种实现网页跳转的方法的区别。

网页A(1.html)

<HTML> 
<HEAD> 
<TITLE>Redirection Speed Test</TITLE> 
<meta http-equiv="Refresh" content="0;url=http://www.baidu.com"> 
</HEAD>
<BODY>
<strong>SHOW ME</strong>
<tr/>
<p>If redirection goes slow evidently.</p>
</BODY> 
</HTML>

网页B(2.html)

<HTML> 
<HEAD> 
<TITLE>Redirection Speed Test</TITLE> 
<script type="text/javascript">
<!--
window.location="http://www.baidu.com";
//-->
</script>
</HEAD>
<BODY>
<strong>SHOW ME</strong>
<tr/>
<p>If redirection goes slow evidently.</p>
</BODY> 
</HTML>

使用浏览器打开上面的两个文件,可以明显的看到,meta标签实现的跳转比较慢,我们可以看到原网页的内容;而js实现的跳转比较快,我们几乎看不到原来网页的内容。

奋斗

原文地址:https://www.cnblogs.com/pangblog/p/3241149.html