meta refresh 和 window.location.href 同时跳转时的时间执行顺序

2020-06-04 by Jinyang | Filed under Uncategorized.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="-1">
    <meta http-equiv="refresh" content="0; url='http://www.baidu.com'">
</head>
<body>
<div style="margin:30% auto;text-align:center; ">
    <p> 
    test
    </p>
</div>
</body>
<script type="application/javascript">
    try {
        window.location.href='http://www.sogou.com';
    }
    catch(err) {
        alert(err.message) ;
    }
</script>
</html>


One Response to “meta refresh 和 window.location.href 同时跳转时的时间执行顺序”

  1. Jinyang says:

    执行结果为: 执行底部的JS跳转。

发表评论

您的电子邮箱不会被公开。 标记为 * 的区域必须填写

返回顶部