博客
关于我
location.href的几种用法
阅读量:804 次
发布时间:2023-02-06

本文共 538 字,大约阅读时间需要 1 分钟。

location.href的几种用法

location.href

  • 在js中,location.href经常用于页面跳转。它主要有如下几种用法:

  • 在当前页面打开URL页面。需要注意的是,window.location.hrefself.location.hrefwindow.location.reload()都是刷新当前页面。但是,如果页面上有提交数据,window.location.reload()会提示是否提交。

  • self.location.href="url"  location.href="url"  window.location.href="url"  this.location.href="url"
  • 在父页面打开URL页面。

  • parent.location.href="url"
  • 在顶层页面打开URL页面。

  • top.location.href="url"

window.open

  • window.open方法用于在一个新窗口中打开URL页面。

  • window.open("url")
  • 上述代码等价于

  • xxx
  • 也可以设置第二个参数为“_self”来实现在当前窗口中打开URL页面。

  • window.open("url","_self")
  • 上述代码等价于

  • xxx

转载地址:http://cbufk.baihongyu.com/

你可能感兴趣的文章
Objective-C实现gaussian filter高斯滤波器算法(附完整源码)
查看>>
Objective-C实现gaussian naive bayes高斯贝叶斯算法(附完整源码)
查看>>
Objective-C实现gaussian高斯算法(附完整源码)
查看>>
Objective-C实现geometric series几何系列算法(附完整源码)
查看>>
Objective-C实现getline函数功能(附完整源码)
查看>>
Objective-C实现gnome sortt侏儒排序算法(附完整源码)
查看>>
Objective-C实现graph list图列算法(附完整源码)
查看>>
Objective-C实现GraphEdge图边算法(附完整源码)
查看>>
Objective-C实现GraphVertex图顶点算法(附完整源码)
查看>>
Objective-C实现greatest common divisor最大公约数算法(附完整源码)
查看>>
Objective-C实现greedy coin change贪心硬币找零算法(附完整源码)
查看>>
Objective-C实现greedy knapsack贪婪的背包算法(附完整源码)
查看>>
Objective-C实现GridGet算法(附完整源码)
查看>>
Objective-C实现half adder半加器算法(附完整源码)
查看>>
Objective-C实现hamiltonianCycle哈密尔顿图算法(附完整源码)
查看>>
Objective-C实现hamming code汉明码算法(附完整源码)
查看>>
Objective-C实现hamming numbers汉明数算法(附完整源码)
查看>>
Objective-C实现hammingDistance汉明距离算法(附完整源码)
查看>>
Objective-C实现hanning 窗(附完整源码)
查看>>
Objective-C实现hanoiTower汉诺塔算法(附完整源码)
查看>>