我一直试图让我的弹出菜单检查用户的屏幕尺寸然后适合屏幕,它适用于除IE9或更低版本之外的所有浏览器,我想制作它至少在IE8上起作用了。愿有人向我解释如何做到这一点。
我的代码: (您应该在桌面上尝试此代码,问题似乎发生在IE 9及更低版本上,但不会出现在模拟器上#s; IE9)
var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
all[0]
);
return v > 4 ? v : undef;
}());
if(ie < 9){
alert("My sincere apologies, but your IE version is not supported!\nUninstall it or go f*ck yourself!");
}
function fe()
{
window.open('http://www.google.com.br','janela','menubar=yes,screenX=0,screenY=0,top=0,left=0,location=no,status=no,toolbar=no,scrollbars=no,resizable=yes,fullscreen=yes,width=' + (screen.width - 15) + ',height=' + (screen.availHeight - 65));
}
function fc(url)
{
var winFeatures = 'screenX=0,screenY=0,top=0,left=0,scrollbars,width=100,height=100';
var winName = 'window';
var win = window.open(url,winName, winFeatures);
var extraWidth = win.screen.availWidth - win.outerWidth;
var extraHeight = win.screen.availHeight - win.outerHeight;
win.resizeBy(extraWidth, extraHeight);
return win;
}
&#13;
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>winds</title>
</head>
<body>
<a href="Javascript:if(ie < 10){fe();}else{fc('');}">Popup</a>
</body>
</html>
&#13;