历史跳转的js

今天老师给我们模仿了一下有关类似历史记录的代码,但它的运行不是依靠游览器里的历史记录。还学习了两个新属性(screen   navigator)下面让我拿简单的代码演示一小下。。。

 <!DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="UTF-8">
 <title>Document</title>
 <script type="text/javascript">
 </script>
 </head>
 <body style="text-align:center;font-size:20px;background:#6ff">
 <a href="javascript:location.href='top2.html';">location的href属性实现跳转</a>
 <br/><br/>
 <a href="javascript:history.go(1);">history的go方法实现前进</a>
 </body>
 </html>
 <!DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="UTF-8">
 <title>Document</title>
 </head>
 <body style="text-align:center;font-size:20px;background:#6ff">
 <a href="javascript:history.back();">history的back方法实现后退</a>
 <br/><br/>
 <a href="javascript:location.reload();">location的reload的方法实现刷新</a>
 </body>
 </html>

以上是在top1和top2里模仿历史记录的

 <!DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="UTF-8">
 <title>Document</title>
 <script type="text/javascript">
 function openWindow(num){
 //web浏览器的可用屏幕宽度,不包括任务栏。
 var winWidth=screen.availWidth/2;
 var winHeight=screen.availHeight/2;
 //窗口居中处理
 var winTop=(screen.availHeight-winHeight)/2;
 var winLeft=(screen.availHeight-winWidth)/2;
 //设计坐标参数字符串
 var para="top="+"+winTop+",left="+winLeft+",width="+winWidth+",height="+winHeight+";
 //打开新的窗口
 var win=window.open("Navigator.html","url,para");
 //是窗口获得焦点
 win.focus();
 }
 </script>
 </head>
 <body>
 <input type="button" value="打开新窗口" onclick="openWindow('1')">
 </body>
 </html>

 <!DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="UTF-8">
 <title>Document</title>
 <script type="text/javascript">
 document.write("浏览器名称:"+navigator.appName+"<br>");
 document.write("浏览器版本:"+navigator.appVersion+"<br>");
 document.write("客户端的操作系统:"+navigator.platform+"<br>");
 </script>
 </head>
 <body>
  
 </body>
 </html>
以上通过按钮调出浏览器的名称,版本和客户端的系统等信息。。。。是不是很神奇
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值