繁体   English   中英

window.location.replace() 不起作用

[英]window.location.replace() is not working

只是想问为什么 window.location.replace 在我的页面中不起作用。 我已经为此工作了好几个星期。 它在我的其他页面上运行良好,虽然这些页面有 DevExpress 组件,但是在这个我只使用普通 html 和 asp 标签和组件的特定页面中它不起作用。 它似乎只是令人耳目一新而不是重定向。 这是我的按钮代码:

<asp:Button ID="btnCancelValidatePassword" runat="server" 
                        CausesValidation="False" ClientIDMode="AutoID" CssClass="ButtonControl" 
                        Height="30px" OnClientClick="window.location.replace('../Account/Settings.aspx')" Text="CANCEL" Width="100px" />

谢谢。

Chrome中重新加载同一页面时,我遇到了它无法正常工作的问题。 执行以下操作:

   window.location.replace("/mypage1.aspx?type=abc"); //redirect to fake page
   window.location.replace("/mypage.aspx?type=abc");  //redirect to same page

这有点像 hack,但这似乎是唯一在 Chrome 中强制重新加载同一页面的东西。 IE 和 FF 无需重定向到虚假页面即可工作。

.replace()String对象的一个​​方法

window.location不是字符串。 改用window.location.href并在window.location.href上调用.replace()

window.location.href.replace(/string_to_be_replaced/, 'string_to_replace');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM