博客
关于我
location.href的几种用法
阅读量:793 次
发布时间: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/

你可能感兴趣的文章
Linux(CentOS)安装 Nginx
查看>>
Linux(RadHat)基础学习—软件安装
查看>>
linux(ubuntu)中crontab定时器命令详解 以及windows中定时器
查看>>
linux(乌班图)修改apt下载源
查看>>
Linux,启动java程序的通用脚本sh
查看>>
Linux:-bash: pip: command not found pip
查看>>
Linux:/dev/tty、/dev/tty0 和 /dev/console 之间的区别
查看>>
Linux:bash: git: 未找到命令...
查看>>
Linux:CentOS安装Docker Compose
查看>>
Linux:CentOS安装Git
查看>>
Linux:fpm打包工具
查看>>
Linux:ldd命令详解
查看>>
Linux:Mysql 大小写配置
查看>>
Linux:mysql中文乱码解决方案
查看>>
Linux:Prometheus安装
查看>>
Linux:Redis开机启动
查看>>
Linux:RPM命令
查看>>
Linux:Ubuntu防火墙
查看>>
Linux:xshell连接centos虚拟机很慢的解决方案
查看>>
Linux:yum安装提示“没有可用软件包”
查看>>