首页 > Windows开发 > 详细

window.location.href 和 window.open 跳转的区别

时间:2021-06-13 09:43:51      阅读:18      评论:0      收藏:0      [点我收藏+]

一、直接跳转式:

window.location.href=\‘https://www.baidu.com\‘

二、开新窗口跳转:

window.open(url, [name], [configuration])

*url:为要新打开页面的url
*name:为新打开窗口的名字,可以通过此名字获取该窗口对象
*configuration:为新打开窗口的一些配置项,比如是否有菜单栏、滚动条、长高等等信息

例子:
新打开一个没有菜单栏、标题栏、工具栏,但是有滚动条、状态栏、地址栏且可伸缩窗口的方法调用如下:

window.open(\"index.html\", \"newWindow\", \"width=1024, height=700, top=0, left=0, titlebar=no, menubar=no, scrollbars=yes, resizable=yes, status=yes, , toolbar=no, location=yes\");

1、参数解释
window.open 弹出新窗口的命令;
index.html 弹出窗口的文件名;
newWindow 弹出窗口的名字(不是文件名),非必须,可用空’\‘代替;
width=1024 窗口宽度;
height=700 窗口高度;
top=0 窗口距离屏幕上方的象素值;
left=0 窗口距离屏幕左侧的象素值;
titlebar=no 是否显示标题栏,被忽略,除非调用HTML应用程序或一个值得信赖的对话框.默认值是yes;
menubar=no 表示菜单栏,默认值是yes;
scrollbars=yes 是否显示滚动条,默认值是yes;
resizable=no 是否允许改变窗口大小,默认值是yes;
status=no 是否要添加一个状态栏,默认值是yes;
toolbar=no 是否显示工具栏,默认值是yes;
location=no 是否显示地址栏,默认值是yes;

2、window.open打开新窗口还是打开新标签页
调用window.open是打开新窗口,还是打开新标签页,这里要加以区分。

window.open(url)或者window.open(url, name),其中name为_blank
标准浏览器、新标签打开链接url

window.open(url, name, configration)
只要配置了configration,都是新窗口打开链接的

window.location.href 和 window.open 跳转的区别

原文:https://www.cnblogs.com/ipython258/p/14879511.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!