location.href和window.open有哪些具体用法和区别?

2026-04-05 21:130阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计1500个文字,预计阅读时间需要6分钟。

location.href和window.open有哪些具体用法和区别?

一、location.href几种常见形式:- self.location.href- //当前页面打开URL页面- window.location.href- //当前页面打开URL页面- this.location.href- //当前页面打开URL页面- location.href- //当前页面打开URL页面

一、location.href常见的几种形式

  1. self.location.href;//当前页面打开URL页面
  2. window.location.href;//当前页面打开URL页面
  3. this.location.href;//当前页面打开URL页面
  4. location.href;// 当前页面打开URL页面
  5. parent.location.href;//在父页面打开新页面
  6. top.location.href;//在顶层页面打开新页面

①如果页面中自定义了frame,那么可将parent、self、top换为自定义frame的名称,效果是在frame窗口打开url地址。

②此外,window.location.href=window.location.href;和window.location.Reload();都是刷新当前页面。
区别在于是否有提交数据。

阅读全文

本文共计1500个文字,预计阅读时间需要6分钟。

location.href和window.open有哪些具体用法和区别?

一、location.href几种常见形式:- self.location.href- //当前页面打开URL页面- window.location.href- //当前页面打开URL页面- this.location.href- //当前页面打开URL页面- location.href- //当前页面打开URL页面

一、location.href常见的几种形式

  1. self.location.href;//当前页面打开URL页面
  2. window.location.href;//当前页面打开URL页面
  3. this.location.href;//当前页面打开URL页面
  4. location.href;// 当前页面打开URL页面
  5. parent.location.href;//在父页面打开新页面
  6. top.location.href;//在顶层页面打开新页面

①如果页面中自定义了frame,那么可将parent、self、top换为自定义frame的名称,效果是在frame窗口打开url地址。

②此外,window.location.href=window.location.href;和window.location.Reload();都是刷新当前页面。
区别在于是否有提交数据。

阅读全文