[英]Open Redirect Action in new window with javascript
我有一個[post]動作返回Redirect(url)。 我想在新標簽中打開此回復。
是否必須使用javascript? :
@using (Html.BeginForm("Action","Controller",FormMethod.Post, new { target = "_blank" }))
{
<input type="submit" value="clickme"/>
}
HTML:
@using (Html.BeginForm("Action", "Controller", FormMethod.Post))
{
<button id="aButton" >Submit</button>
}
使用jQuery的Javascript:
$('#aButton').click(function (event) {
event.preventDefault();
var form = $(this).parent('form');
form.attr('target', '_blank');
form.submit();
});
通過這種方式,您可以按原樣保留操作,如果要提交其他表單變量,則可以將其包含在表單中。
上面的解決方案是不引人注目的,並且如果禁用了javascript則可以使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.