js技巧专题篇: 页面跳转
本篇主要介绍网页上常见的页面跳转技术。页面跳转有几种方式,比较常用的是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技巧专题篇: 页面跳转的更多相关文章
- JS是否确认提示 +页面跳转
JS友好提示 +页面跳转 function logout()...{if (confirm("你确定要注销身份吗?是-选择确定,否-选择取消"))...{window.locati ...
- JS页面跳转和js对iframe进行页面跳转、刷新
一.js方式的页面跳转1.window.location.href方式 <script language="JavaScript" type="text/ja ...
- js如何在指定页面跳转到另一指定页面
要实现从一个页面A跳到另一个页面B,js实现就在A的js代码加跳转代码 JS跳转大概有以下几种方式: 第一种:(跳转到b.html)<script language="javascri ...
- Js 的常用方法:页面跳转,Session,类继承
MyApp.Base = function () { } var basePrototype = MyApp.Base["prototype"]; //对象克隆方法 basePro ...
- 用js 获取url 参数 页面跳转 ? 后的参数
记得之前在原来的公司写过这个东西,但是还是忘记怎么接住参数了,只知道怎么把id传过去! 问了身边的大佬 他首先推荐了我一个链接是别人写好的方法 附上链接地址:http://blog.csdn.net/ ...
- JS中的集中页面跳转的方法
第一种: <script language="javascript" type="text/javascript"> wi ...
- js中常用framesetiframe页面跳转传参方法实例大全
logf的空间
- js获取主机名实现页面跳转
<script language="javascript" type="text/javascript"> var hostname ...
- 自定义PHP页面跳转函数redirect($url, $time = 0, $msg = '')
利用PHP的header()函数,可以实现页面跳转,如 header("Location: " . $url); 但它有个缺点,一旦HTTP报头块已经发送,就不能使用 header ...
随机推荐
- 1.3用socketserver创建服务器
socket服务器代码 # -*- coding: utf-8 -*-import socketserver,time myHost = '' myPort = 50007 def now(): #返 ...
- windows剪贴板
0x01 Windows剪贴板 Windows剪贴板是一种比较简单同时也是开销比较小的IPC(InterProcess Communication,进程间通讯)机制.Windows系统支持剪贴板IP ...
- js 冒泡事件阻止 父层事件影响子层
当父层 与子层 有相同的事件时,但子层跟父层执行的内容却不一样时 为了 防止 父层事件对子层造成影响我们可以在子层的方法里做如下操作 function A (event){ event.stopPro ...
- 《图解HTTP》读书笔记(转)
reference:https://www.cnblogs.com/edisonchou/p/6013450.html 目前国内讲解HTTP协议的书是在太少了,记忆中有两本被誉为经典的书<H ...
- matlab中hold on 和hold off功能的区别
hold off 使但当前轴及图形不具备被刷新的性质 hold on和hold off是相对使用的 前者为,你在当前轴(坐标系)中画了一幅图,再画另一幅是,原来的图还在,与新图共存,都看得到: 后者表 ...
- Java NIO:浅析I/O模型(转)
原文链接:http://www.cnblogs.com/dolphin0520/p/3916526.html 以下是本文的目录大纲: 一.什么是同步?什么是异步? 二.什么是阻塞?什么是非阻塞? 三. ...
- vue中七牛插件使用
<template> <div id="cxUpload" class="cx-upload"> <button id=" ...
- Metasploit的射频收发器功能 | Metasploit’s RF Transceiver Capabilities
https://community.rapid7.com/community/metasploit/blog/2017/03/21/metasploits-rf-transceiver-capabil ...
- Python 数据结构--排序
各种排序的时间复杂度和空间复杂度 以下 冒泡排序,选择排序,插入排序,合并排序,快速排序,希尔排序 1 冒泡排序(Bubble Sort) 冒泡排序(Bubble Sort)是一种简单的排 ...
- Centos7防火墙开放8080端口
查看已经开发的端口: firewall-cmd --list-ports 开启端口: firewall-cmd --zone=public --add-port=8080/tcp --permanen ...