The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Dynamic window size on window.open
Robbie
post Dec 21 2011, 05:28 PM
Post #1





Group: Members
Posts: 2
Joined: 21-December 11
Member No.: 16,125



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");
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Dec 21 2011, 08:32 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Dec 21 2011, 10:07 PM
Post #3


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Robbie
post Dec 22 2011, 10:29 AM
Post #4





Group: Members
Posts: 2
Joined: 21-December 11
Member No.: 16,125



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 29th March 2024 - 09:52 AM