本篇主要介绍网页上常见的页面跳转技术。页面跳转有几种方式,比较常用的是window.location.href,window.location.replace,window.open,当然还有目前比较火的很多框架都采用的无刷新页面跳转技术window.history.pushState和window.history.replaceState。这些我都不讲^_^,我这里讲得是meta的一个相关配置。我相信,很多朋友看见实现的页面时会非常面熟,特别是男性!

以下是相关代码实现:

 <!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta http-equiv="refresh" content="5;url=https://www.baidu.com"/>
<title></title>
<style>
span {
color: red;
padding: 5px 15px;
background: #cccccc;
}
button {
padding: 10px;
display: inline-block;
vertical-align:top;
border-radius: 4px;
outline: none; }
</style>
</head>
<body>
<h1>对不起您浏览的页面已改变,<span>5</span> 秒后自动为您跳转... <button>手动跳转</button>
</h1>
<script>
var span = document.querySelector('span'),
btn = document.querySelector('button');
var selfTimer = (function(){ var i = 5;
return function(){
span.innerHTML = --i;
if (i == 0)
{ clearInterval(timer);
} } })()
timer = setInterval(selfTimer, 1000);
btn.onclick = function() {
window.location.hash = 'https://www.baidu.com'; }
</script>
</body>
</html>

最后感谢慕课网的:
 作者:外号理论汪 
来源:慕课网

js技巧专题篇: 页面跳转的更多相关文章

  1. JS是否确认提示 +页面跳转

    JS友好提示 +页面跳转 function logout()...{if (confirm("你确定要注销身份吗?是-选择确定,否-选择取消"))...{window.locati ...

  2. JS页面跳转和js对iframe进行页面跳转、刷新

    一.js方式的页面跳转1.window.location.href方式    <script language="JavaScript" type="text/ja ...

  3. js如何在指定页面跳转到另一指定页面

    要实现从一个页面A跳到另一个页面B,js实现就在A的js代码加跳转代码 JS跳转大概有以下几种方式: 第一种:(跳转到b.html)<script language="javascri ...

  4. Js 的常用方法:页面跳转,Session,类继承

    MyApp.Base = function () { } var basePrototype = MyApp.Base["prototype"]; //对象克隆方法 basePro ...

  5. 用js 获取url 参数 页面跳转 ? 后的参数

    记得之前在原来的公司写过这个东西,但是还是忘记怎么接住参数了,只知道怎么把id传过去! 问了身边的大佬 他首先推荐了我一个链接是别人写好的方法 附上链接地址:http://blog.csdn.net/ ...

  6. JS中的集中页面跳转的方法

    第一种:    <script language="javascript" type="text/javascript">           wi ...

  7. js中常用framesetiframe页面跳转传参方法实例大全

    logf的空间

  8. js获取主机名实现页面跳转

    <script language="javascript" type="text/javascript">        var hostname ...

  9. 自定义PHP页面跳转函数redirect($url, $time = 0, $msg = '')

    利用PHP的header()函数,可以实现页面跳转,如 header("Location: " . $url); 但它有个缺点,一旦HTTP报头块已经发送,就不能使用 header ...

随机推荐

  1. Redis部署与基本操作

    1.安装 1)不指定安装位置,则会把redis的可执行文件安装到  redis-2.8.6/src/目录下 [root@CentOS6 ~]# ls anaconda-ks.cfg  httpd-2. ...

  2. POJ - 2635 E - The Embarrassed Cryptographer

    The young and very promising cryptographer Odd Even has implemented the security module of a large s ...

  3. 20165326 学习基础和c语言基础调查

    学习基础和c语言基础调查 一.关于个人技能 阅读了娄老师关于做中学的文章,我想起了自己之前学习技能的经历. 从小到大我学过的东西不少,除学校的教育课程外,我还参加过各种兴趣班,书法.绘画.舞蹈.吉他. ...

  4. 适配手机端之 rem

    (function() { var psdWidth = 1080, maxRem = 100, ch = document.documentElement.clientHeight || docum ...

  5. Selenium之ActionChains(一)

    今天,分享的是ActionChains的使用方法. 先来说一下今天要用到的方法: click(element=null)                                 点击元素,参数 ...

  6. Smali插桩打日志

    一.smali目录下新建crack.smali,内容如下: .class public Lcrack; .super Ljava/lang/Object; .source "crack.ja ...

  7. 【leetcode】20-ValidParentheses

    problem Valid Parentheses code class Solution { public: bool isValid(string s) { stack<char> p ...

  8. verilog实现rgb2gray

    前言 项目算法需求,需要将RGB彩色图像转换为灰度图像,算法原理是很简单的,但是对于刚接触FPGA的宝宝来说,进行时序的设计和调试还是不那么容易的,为了省事儿,就按照上一篇中值滤波(http://ww ...

  9. 检测IP地址冲突的shell脚本-check_server_ip_conflict.sh

    check_server_ip_conflict.sh 使用arping获取对应IP地址的MAC地址,如果和预料的不一致则报警: #!/bin/bash epg_addr_01="00:50 ...

  10. [LeetCode&Python] Problem 563. Binary Tree Tilt

    Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the ab ...