I am trying to open a popup window, so that it height is from the top of the screen to the "applications" bar of Windows. This is the code:
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;
}
Why doesnt it work in IE? (works in chrome)
Thanks
I am trying to open a popup window, so that it height is from the top of the screen to the "applications" bar of Windows. This is the code:
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;
}
Why doesnt it work in IE? (works in chrome)
Thanks
Share Improve this question edited Jan 17, 2017 at 21:28 Skeets 4,8383 gold badges47 silver badges73 bronze badges asked Jan 27, 2012 at 15:27 KenciKenci 4,88216 gold badges69 silver badges113 bronze badges3 Answers
Reset to default 9I think you only need screen.width and screen.height. Don't prepend them with window.
Edit: Apparently IE requires a "fullscreen=yes" param.
Try this:
<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>
This works for me:
<a class="popme" href="http://codesheet">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;
});
});
Demo: http://codesheet/codesheet/JMbOYCUI
if you just want to open new window in full screen, did you try remove the height and width parameters?
newWindow = window.open(windowUri, windowName);
see reference