博客
关于我
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/

你可能感兴趣的文章
nginx 禁止以ip形式访问服务器
查看>>
NGINX 端口负载均衡
查看>>
Nginx 结合 consul 实现动态负载均衡
查看>>
Nginx 负载均衡与权重配置解析
查看>>
Nginx 负载均衡详解
查看>>
Nginx 负载均衡配置详解
查看>>
nginx 配置 单页面应用的解决方案
查看>>
nginx 配置dist 加上跨域配置
查看>>
nginx 配置https(一)—— 自签名证书
查看>>
nginx 配置~~~本身就是一个静态资源的服务器
查看>>
Nginx 配置服务器文件上传与下载
查看>>
Nginx 配置清单(一篇够用)
查看>>
Nginx 配置解析:从基础到高级应用指南
查看>>
Nginx 集成Zipkin服务链路追踪
查看>>
nginx 集群配置方式 静态文件处理
查看>>
Nginx+Django-Python+BPMN-JS的整合工作流实战项目
查看>>
Nginx+Keepalived+LVS集群实战
查看>>
Nginx+Keepalived实现简单版高可用主备切换
查看>>
nginx+mysql+redis+mongdb+rabbitmq 自动化部署脚本
查看>>
nginx+php的搭建
查看>>