Help - Search - Members - Calendar
Full Version: Dynamic window size on window.open
HTMLHelp Forums > Programming > Client-side Scripting
Robbie
Hi, I am new to JS and I have this requirement in my project. On click of a link from the window, we are to open a new window. While opening the window it has to be dynamically adjusted according to the screen's width & height.
I have already tried document.documentElement.offsetHeight, screen.Height, document.body.offsetHeight etc... I am more concerned on getting the height correctly. It should open to the window's height and width in different systems based on its different resolutions.
It will be open in IE only.

I am not sure whether this is the right place to post, or whether this has already been discussed a lot of times. I am not aware of where to search at this moment. Please let me know how this can be done. Many thanks...


var winHeight=document.documentElement.offsetHeight;
var winWidth=document.body.offsetWidth;

window.open(oSafeURL,"_blank","resizable=1,status=1,scrollbars=1,width="+winWidth+",height="+winHeight+",left=0,top=0");
pandy
Try these.
http://www.javascriptkit.com/howto/newtech3.shtml

What happened when you used screen.height? If you really spelled it with a capital H, that was the problem.
Christian J
This should work:

CODE
window.open('popup.html', 'foo', 'width='+screen.availWidth+', height='+screen.availHeight);

Alas the window is not centered but placed a little to the side. IIRC this can be changed as well.

Also IE9 is a bit strange: my screen width is 1280px, but screen.availWidth returns 1350px. unsure.gif
Robbie
Hi, Thanks for your reply.
My screen resolution is 1366 by 768 pixels. I used screen.availHeight as suggested. Now the height is 738, however some portion of statusbar still hides behind the taskbar.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.