Solved

Resizing popup window dynamically after creation

Posted on 2008-11-01
5
863 Views
Last Modified: 2013-12-13
Hi folks,

Perhaps this is a rather simple answer, but once you have created a new popup window through a javascript call, is there any way to vertically resize the window based on the extent of the PHP dynamically rendered content?

Example, I am creating a PHP based popup calendar for my client, but some months have 5-6 rows of days that appear. (You can see the working example at http://www.mmcfc.org/test.htm )
If you go back to October using the << link, it fits in the window just fine, but if you come back to November..then, as you can see, the day rows breach the bottom of the fixed size of the popup window.

Any suggestions would be appreciated.

Thanks
0
Comment
Question by:adrian_brooks
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:wilq32
ID: 22859721
just try: window.resizeTo(800,600)  for example :) Dynamically ? you will need to give value by yourself, so if you need it autochanging - you have to count width of your content.
0
 
LVL 12

Author Comment

by:adrian_brooks
ID: 22859745
Hmmmm

but is there anyway of knowing how much vertical space is being consumed by the content after being rendered to the page?

I don't know if you got to check out the link I added, but as you can see, November clearly makes that window far too small. Should I possibly just statically define heights based on which month of the year is displayed then and just make my initial javascript popup call predefined with those values perhaps?
0
 
LVL 18

Accepted Solution

by:
wilq32 earned 500 total points
ID: 22860609
after rendering your page just check offsetHeight of div containg calendar:

function loader()
{
window.resizeTo(document.getElementById('main-wrapper').offsetWidth+30, document.getElementById('main-wrapper').offsetHeight+30);

}


in body tag of this element:

<body onload="loader()">


Should work
0
 
LVL 12

Author Closing Comment

by:adrian_brooks
ID: 31512420
wilq32...you rock, man!

That's exactly what the doctor ordered! :)
With a few adjustments, I am able to get it to open to proper sizing. :)

Thanks :)
0
 
LVL 19

Expert Comment

by:NerdsOfTech
ID: 22861843
I would start off by getting the width you want to set based on your current width *FIXED*... you can get the current size by running the code below in your popup page. You can then figure out what heights are changing to to get a feel of what you are dealing with. After then you can run the resize script right from your calendar (<body onload="start the above code resize function based on div tag container">). Just make sure your script code is in the <head> of your calander code.

size alert source: EE archrajan:

=NerdsOfTech
<head>

<script>

function alertSize() {

  var myWidth = 0, myHeight = 0;

  if( typeof( window.innerWidth ) == 'number' ) {

    //Non-IE

    myWidth = window.innerWidth;

    myHeight = window.innerHeight;

  } else if( document.documentElement &&

      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {

    //IE 6+ in 'standards compliant mode'

    myWidth = document.documentElement.clientWidth;

    myHeight = document.documentElement.clientHeight;

  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {

    //IE 4 compatible

    myWidth = document.body.clientWidth;

    myHeight = document.body.clientHeight;

  }

  window.alert( 'Width = ' + myWidth );

  window.alert( 'Height = ' + myHeight );

}
 

</script>

</head>

<BODY>

<input type="button" onclick=alertSize();" value="Check Size">

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
grab and show facebook pages event calendars 6 46
Jquery autocomplete 10 31
sql sentence 2 13
Web Reply Form - PHP with Upload 4 21
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now