当我使用FB.login
JavaScript SDK 中的函数时,会出现弹出窗口,但它一直向右对齐并出现在第二个监视器屏幕上。仅当浏览器窗口最大化时才会发生这种情况,如果未最大化弹出窗口正确居中。可在 IE 10、Firefox 20 中重现
问问题
776 次
2 回答
2
我最终覆盖了 window.open 并更改了属性字符串中的 left=。FB API 出于某种原因在其中放了非常多的数字。
于 2013-05-30T07:28:29.843 回答
0
Window.open overide 也为我工作......
放置代码片段来帮助它:
window.open = function (open) {
return function (url, name, features) {
var w = 475;
var h = 183;
// 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;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var 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 override_features = 'width=475,height=183,left=' + left + ',top=' + top + ',scrollbars=1,location=1,toolbar=0';
// set name if missing here
//name = name || "default_window_name";
return open.call(window, url, name, override_features);
};
}(window.open);
w = 所需的弹出窗口宽度 h = 所需的弹出窗口高度
你使用override_feature
变量来设置你想要的任何参数。
于 2016-10-07T09:53:55.800 回答