如何区分并详细解析js中location.href与window.open的多种使用方法?

更新于
2026-09-28 12:37:59
0阅读来源:SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

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

如何区分并详细解析js中location.href与window.open的多种使用方法?

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

1.self.location.href

2.window.location.href

3.this.location.href

4.location.href

5.parent.location.href

一、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();都是刷新当前页面。
区别在于是否有提交数据。

阅读全文

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

如何区分并详细解析js中location.href与window.open的多种使用方法?

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

1.self.location.href

2.window.location.href

3.this.location.href

4.location.href

5.parent.location.href

一、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();都是刷新当前页面。
区别在于是否有提交数据。

阅读全文