首页/javascript外包/window.open()与window.location.href的区别
<上一条:JS获取当前页面的URL
下一条: JS中的location属性和方法总结 >
window.open()与window.location.href的区别
发布-xiaoming | 浏览量-
window.open()与window.location.href的区别
window.open("index.html",'top'); 只是表示打开这个页面,并不是打开并刷新index.html
window.location.href="index.html"; 表示重新定向到新页面,同时刷新打开的这个页面;
eg:
<tr><td style="width:96%;">进行中项目</td><td><img alt="" src="Images/demo.gif" style="text-align:right;cursor:hand;" onclick="javascript:window.open('test.html?flag=0','_top');"/></td></tr>
<tr><td style="width:96%;">进行中项目</td><td><img alt="" src="Images/demo.gif" style="text-align:right;cursor:hand;" onclick="javascript:window.location.href='test.html?flag=0';"/></td></tr>
这两个的效果不同
上一条: JS获取当前页面的URL
下一条: JS中的location属性和方法总结
或许你还对下面的文章感兴趣