我正在尝试打开一个弹出窗口,使其高度从屏幕顶部到Windows的“应用程序”栏。这是代码:
function windowOpener(windowHeight, windowWidth, windowName, windowUri) {
var windowHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
var centerWidth = (window.screen.width - windowWidth) / 2;
var centerHeight = (window.screen.height - windowHeight) / 2;
newWindow = window.open(windowUri, windowName, 'resizable=0,scrollbars=1,width=' + windowWidth +
',height=' + windowHeight +
',left=' + centerWidth);
newWindow.focus();
return newWindow.name;
}
为什么它在IE中不起作用? (在chrome中工作)
谢谢
答案 0 :(得分:9)
我认为你只需要screen.width和screen.height。不要在窗口前面添加它们。
编辑:显然IE需要“全屏=是”参数。
试试这个:
<script type="text/javascript">
<!--
function popup(url)
{
params = 'width='+screen.width;
params += ', height='+screen.height;
params += ', top=0, left=0'
params += ', fullscreen=yes';
newwin=window.open(url,'windowname4', params);
if (window.focus) {newwin.focus()}
return false;
}
// -->
</script>
<a href="javascript: void(0)"
onclick="popup('popup.html')">Fullscreen popup window</a>
答案 1 :(得分:1)
这对我有用:
<a class="popme" href="http://codesheet.org">popup</a>
的jQuery
$(document).ready(function() {
$(".popme").click(function(event){
var h = 650;
var w = 340;
var wh = screen.height;
var ww = screen.width;
var top = wh/2 - h/2;
var left = ww/2 - w/2;
var popup = window.open(this.href + '', 'player', 'height=' + wh + ', width=' + w + ', scrollbars=no, left=' + left + ', top=' + top);
popup.focus();
return false;
});
});
答案 2 :(得分:0)