PDA

View Full Version : window resize script - sporadic problem - need to delay somehow?



pavinder
Jun 23rd, 2007, 04:42 PM
Hi, I've done a lot of searching and found some useful scripts to get variable sized popup windows to open, particularly in the thread:
http://www.codingforums.com/archive/index.php?t-72231.html

As it's archived I can't add to that thread so am resurrecting it here, apologies if I should have reposted all the code too.

I'm having the same problem as the original poster there - the new windows sometimes don't resize.

Now although the other suggestions on that thread are working alternatives, neither really fits my needs (as I'd like to have html in the new window, not just an image). so I'd like to be able to use the method in the original script and tweak it to work.

Putting alerts etc in the code I've found that the issue is that the values of pic.width and pic.height are zero. Not always though - it's a sporadic problem. Would I be right in assuming that the assignment statements:
t+=' var wd=pic.width+50;\n';
t+=' var ht=pic.height+80;\n';
could be occurring before the image has been fully loaded, or something like that?
Therefore putting a delay in the code before those statements should help, right? Unfortunately it doesn't, the problem still sometimes occurs.

What might be causing this then?

I need to modify other features of the popup window, for example set the background colour by using:
TheNewWindow.document.getElementsByTagName('body')[0].style.backgroundColor='#000000'

Therefore the other script on the page, the last one, isn't a good starting point for my needs as there is no html code in the new window (and so no "body" tag).
However, if there was an alternative way of modifying window features then something based on this script could do the job. Is there such a way?

Finding a solution to either of these issues would help greatly.

Thanks in advance for your help...

glenngv
Jun 23rd, 2007, 05:20 PM
Try this:
http://www.codingforums.com/showthread.php?t=9836#post47403

pavinder
Jun 23rd, 2007, 11:25 PM
Looks just the ticket....thanks so much. Will adapt it and run some in-depth tests.