window.location的或window.location.href不是在所有的浏览器MVC应用程序更改值 [英] window.location or window.location.href not changing the value in all browsers MVC application
问题描述
当前URL为
我在我的页面取消按钮whenvever取消按钮点击需要从位于aother文件夹中的不同作用的结果导航
i have cancel button in my page whenvever cancel button clicked need to navigate from different action result which is located in aother folder
例如:关于/结果(即 http://xx.com/About/结果)我有以下code在我的取消功能
Ex: About/Result (i.e. http://xx.com/About/Result) i have below code in my cancel function
function cancel() {
window.location = '@Url.Action("Result", "About")';
return false;
}
尝试了所有的办法像
tried all the ways like
window.location.href= "/About/Result"
window.location.pathname="/About/Result"
,但还是没有改变旧value.it只保留旧值。
提到这么多的链接像
<一个href=\"http://stackoverflow.com/questions/13443974/window-location-href-does-not-change-the-url\">window.location.href不改变网址
https://developer.mozilla.org/en-美国/文档/网络/ API / window.location的
但是当我尝试给
window.location.href="http://www.google.com"
正常工作。为什么我不能从行动导航到不同的目录其他操作。什么问题?
it works fine. why i can't navigate from on action to another action from different directory. any problem ?
什么是确切的根源?
推荐答案
找到了解决办法参照下面的链接
found the solution by referring the following link
<一个href=\"http://stackoverflow.com/questions/275092/windows-location-href-not-working-on-firefox3\">windows.location.href不工作的Firefox3的
需要添加回报像
<button id="btnCancel" class="btn" onclick="return cancel()">
在您标记的网页,即呼吁点击此函数必须返回此函数的值控制。
in your markup for the page, the control that calls this function on click must return this function's value.
function cancel() {
window.location.href = "../../About/Index";
return false;
}
这篇关于window.location的或window.location.href不是在所有的浏览器MVC应用程序更改值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!