...

View Full Version : How do I make a popup window reshape according to screen area size?



ubernoob
08-01-2002, 04:49 PM
Alright, I could use alittle help on this one if anyone knows how to do it. What I want to do is get a popup window to reshape itself to fit accordly to different browsers screen area size.

What I am using the code for is an online auction site, where I have a small picture in my auctions and when the picture is clicked it opens up a larger version of the picture in a window, and has a close this window link in the popup for easily closing it.

The only problem I'm having is when I test it on different screen area sizes it's not showing the whole popup. Like for instance on a 600-800 it won't show the close the window link. Or the window will be to large to even see the whole picture. I tried putting in a scrolling bar but that didn't work either.


The script I used in the heading is this:

<SCRIPT language="JavaScript">
<!--
function Popup()
{
var popupURL ="EDITED";
var popup = window.open(popupURL,"Popup",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=50 0');
if( navigator.appName.substring(0,8) == "Netscape" )
{
popup.location = popupURL;
}
}
// -->
</SCRIPT>

I pulled that script off a tutorial site, as I wasn't to knowledgeable of javascript when I first started this project.

I use this script as the link where my picture is on the auction:

<A HREF="javascript:Popup()" ><img src="EDITED" height=100 width=100></A>

I pulled that off the same tutorial site. I messed around with the width and height attributes for awile but I don't know if those are whats affecting the way it's viewed. I edited out the the picture and url I used, but if it's needed I'll put them back in.

I want to thank anyone ahead of time for any responses to my question. I really appreciate you taking the time to try and help me out.

Mrs G
08-01-2002, 09:34 PM
Try the following


<SCRIPT language="JavaScript">
<!--
Width=screen.width
Height=screen.height
function Popup(){
var popupURL ="EDITED";
var popup = window.open('popupURL','Popup' ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+Width+",height="+Height+"');
if( navigator.appName.substring(0,8) == "Netscape" ){
popup.location = popupURL;
}
}
// -->
</SCRIPT>
<A HREF="javascript:Popup()" ><img src="EDITED" height=100 width=100></A>

ubernoob
08-02-2002, 02:57 AM
That doesn't seem to work. The popup doesn't open now. When I click on the picture that is supposed to open the popup I get error on page message on the very bottom bar.

Am I supposed to specifiy the exact width and height I want the popup to open to?

Mrs G
08-02-2002, 07:54 PM
I think you will find the script will work.
The problem is how the text in this textbox is wrapped.

I copied and pasted the above script and got an error because the window.open line had been broken.

the following should be one line

var popup = window.open('popupURL','Popup' ,'toolbar=0,location=0,directories=0,status=0,menu
bar=0,scrollbars=0,resizable=0,width="+Width+",height="+Height+"');

I've attached a text file with the code in.

ubernoob
08-03-2002, 04:00 PM
I want to thank you so much for getting that popup to work right.

Only problem I have now is the popup isn't showing the picture anymore. Just a cannot find server message.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum