问题描述
|
我有一个带有按钮的网站,它会打开一个包含信息的弹出窗口。单击此按钮后,我希望带有按钮的窗口导航到新窗口。希望使用Url.Action命令。以下代码是我的尝试,但不起作用。第二部分<%= Url.Action(\“ MainScreenAction \”,\“ Controller \”)%>是应浏览主屏幕的内容。但是它停止了一切工作。
<input type=\"button\" value=\"test\" onclick=\"openwindow(\'<%=Url.Action(\"PopupWindowAction\",\"Controller\")%>\');<%=Url.Action(\"MainScreenAction\",\"Controller\")%>\"/>
Openwindow()是一个javascript函数,仅允许我打开传递的href(url.action)在弹出窗口中将其打开。
编辑:我忘了提到这是在asp.net MVC中
解决方法
您必须设置窗口的位置
<input type=\"button\" value=\"test\"
onclick=\"openwindow(\'<%=Url.Action(\"PopupWindowAction\",\"Controller\")%>\');window.location=\'<%=Url.Action(\"MainScreenAction\",\"Controller\")%>\';\"/>
,您需要为此设置window.location.href。试试下面的代码:
function reloadWindow(url)
{
window.location.href = url;
}
<input type=\"button\" value=\"test\"
onclick=\"openwindow(\'<%=Url.Action(\"PopupWindowAction\",\"Controller\")%>\');reloadWindow(\'<%=Url.Action(\"MainScreenAction\",\"Controller\")%>\');\"/>