• window.location与window.open()的区别


    "top.location.href"是最外层的页面跳转
    "window.location.href"、"location.href"是本页面跳转
    "parent.location.href"是上一层页面跳转.

    location是window对象的属性,而所有的网页下的对象都是属于window作用域链中(这是顶级作用域),所以使用时是可以省略window。而top是指向顶级窗口对象,parent是指向父级窗口对象。 

      window.location是window对象的属性,而window.open是window对象的方法 
      window.location是你对当前浏览器窗口的URL地址对象的参考!   
      window.open是用来打开一个新窗口的函数! 

    window.open()是可以在一个网站上打开另外的一个网站的地址 
    而window.location()是只能在一个网站中打开本网站的网页 

    window.location或window.open如何指定target? 
    这是一个经常遇到的问题,特别是在用frame框架的时候 
    解决办法: 
    window.location 改为 top.location 即可在顶部链接到指定页 
    或 
    window.open("你的网址","_top"); 

    <input type="button" value="新窗口打开" onclick="window.open('http://www.baidu.com')">
    <input type="button" value="当前页打开" onclick="top.location='http://www.baidu.com','_top'">

    window.location.href = "C.html"

  • 相关阅读:
    最短路
    Codeforces Round #607 (Div. 2) C. Cut and Paste
    第三次训练赛
    训练赛
    day27-反射
    day26-网络编程
    tcp文件上传--多个客户端
    tcp图片上传
    tcp文件上传优化
    tcp文件上传
  • 原文地址:https://www.cnblogs.com/wzihan/p/13179144.html
Copyright © 2020-2023  润新知