我想尝试在提交时更改操作,然后单击并打开新窗口itz在新选项卡中打开并工作,但我想在新窗口中打开
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "ReferralForm" }))
{
<input id="fbPost" type="submit" value="Post" style="background-color:#314F8F;" class="white"/>
}
$('#fbPost').click(function () {
$('#ReferralForm').attr({
action: '@Url.Action("FacebookLogin", "Agent")',
target: '_blank'
});
要获得弹出窗口而不是新选项卡,您必须设置窗口的尺寸。 我前段时间在网上看了一下,发现了这个功能
function PopupCenter(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
var newWindow = window.open(url, title, 'model=yes,menubar=no,status=no,toolbar=no,location=no,width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
// Puts focus on the newWindow
if (window.focus) {
newWindow.focus();
}
}
我不记得给他们信用的来源。 然后像这样调用函数。
var url = '@Url.Action("FacebookLogin", "Agent")';
PopupCenter(url, "Popup", 800, 600);
我找到了这个功能,因为它确定您的窗口大小并设置窗口,使其在打开时居中。 希望这有帮助。