PDA

View Full Version : Problem with auto resizing windows.


GLHeX
08-02-2002, 10:52 PM
Hello,


okay I did run about four searches in the forums but could not find the answer to my question.

Okay I used the tutorial on Actionscript to generate some Java pop up scripts.

(URL)
http://www.actionscripts.org/tutorials/beginner/spawn_browser/index.shtml


Well needless to say it works great. However my problem is as such,

I have a menu with portfolio pieces, when you click on the thumbnail the accual large file pops up into a window to fit that image size.

But if you dont close the pop up and open another the window -retains its shape/size-

(thus if someone clicked on a 100x100 images first, then tried to opeb a 200x200 image half of it would be cut off)

So the only way to avoid this is to close the pop up first -then- click on other thumbnails.



Is there anyway to set in the java script to either

A) Close the last window and open a new (i dont think that possible)

B) FORCE the current -open- window to resize.

or

C) Just open a new window and not use the currently open one. (so the user would just open window after window untill he/she started to close them )


I hope this is all clear.

This wouldnt be a problem if all my images were the same size, however most completly differ in size.


Thanks for reading

gl

tg
08-02-2002, 11:14 PM
easiest first:
c.) multiple windows:
in your javascript, change the "name" argument for each window, and it will open a new window every time.
a.) close the window then reopen:
(this is untested, and may not work):
cut and paste this code into your html in place the the code you were using before:

<script language="JavaScript">
<!--
function spawnWindow(URL,Name,features) {
if(!newWin.closed){newWin.close()};
newWin=window.open(URL,Name,features);
}
//-->
</script>

b.) resize window:
(this is untested, and may not work):
follow this instructions in the tutorial, but include the line of code under the getURL action. for this to work, the resizable property must be 'yes' and you need to know the width and height of the file your loading into the page.

<script language="JavaScript">
<!--
function spawnWindow(URL,Name,features,myWidth,myHeight) {
if(!newWin.closed){newWin.close()};
newWin=window.open(URL,Name,features);
newWin.resizeTo(myWidth,myHeight);
}
//-->
</script>

GLHeX
08-02-2002, 11:21 PM
Great!

Thank you so much! =]

tg
08-02-2002, 11:31 PM
which one did you try? did it work ok?

GLHeX
08-02-2002, 11:51 PM
The first one works fine. (c)

I tried out the second (a) and wasnt able to get it to work and I have not tried the third one (b) out yet.