window.open("index.aspx",'top'); 只是表示打开这个页面,并不是打开并刷新index.aspx
window.location.href="index.aspx"; 表示重新定向到新页面,同时刷新打开的这个页面;
eg:
<tr><td style="width:96%;">进行中项目</td><td><img alt="" src="Images/2emorewe.gif" style="text-align:right;cursor:hand;"
onclick="javascript:window.open('ProjectList.aspx?flag=0','_top');"/></td></tr>
<tr><td style="width:96%;">进行中项目</td><td><img alt="" src="Images/2emorewe.gif" style="text-align:right;cursor:hand;" onclick="javascript:window.location.href='ProjectList.aspx?flag=0';"/></td></tr>
这两个的效果不同
版权声明:本文为博主原创文章,未经博主允许不得转载。
本文介绍了JavaScript中window.open()与window.location.href的区别。前者用于打开新窗口或标签页,而后者则用于重新定向当前窗口到新的URL并刷新页面。通过具体的代码示例,展示了两种方法的不同应用场景。
656

被折叠的 条评论
为什么被折叠?



