PDA

View Full Version : popup window help


dionnesimone
02-02-2003, 07:43 PM
www.dionnesimone.com (http://www.dionnesimone.com)
In the home -> about -> webcam part - error on page....

<u>What I am trying to accomplish</u>:
I want thumbnails of certain pics - then when you click on them a popup window opens with the image inside resized to the size of the image. I'm having problems with just opening a pop-up right now but I would also like to put in code so that if I clicked on a different thumbnail the image would appear in that same pop-up window.... Don't want all kinds of pop-up windows popping up.

Can someone help.... ???

~ D.

ConfusedOfLife
02-02-2003, 08:17 PM
It's the 3rd post in these 2 weeks that I'm answering ppl looking for a pop up window! It's getting really boaring. Anyways, to be frank with you, I'm not going to debug your code coz I'm not in a debuging mood tonight!

What I suggest is that you have a variable like myImg in your main page ( where you show all the thumbnails ) and when someone clicks on an image, if it's the first time, you open the pop up window, that should contain a script that checks the value of the main pages variable that you defined ( as I always forget to say, myImg should contain the address of each clicked on image! You can easily do this by defining an onclick trigger for each image and assigning it's address to myImg ) and put the approperiate picture in the page ( I'm talking about the pop up window that this checking should happen in there ), but if it's not the first time that someone clicks on the image, you should simply refresh your pop up window. When it's refreshed, it means that the compiler starts at the beginning and it goes and checks for the main page's variable and puts the relevant pic on the page and ....

Of course there are lots of ways to do this, but it's the easiest, me thinks!

Hope that it helped.

justame
02-02-2003, 08:24 PM
dio...
/me has this just a copied/pasted/saved/credited® to reyn from the ol' wa forum...:O)))

Well, that's just a matter of knowing the image's dimensions beforehand, and using that
as the parameters for opening a window of the specified size.

This simple reusable function can be called by any link that passes it the image
filename, and the height and width of the image, then pops out the image in a new
window of approximately that size.

Somewhere in the HEAD, insert:

<script language="JavaScript">
<!--
function show(pic,h,w){
var size="height="+h+",width="+w;
var show=open(pic,'',size)}
//-->
</script>

And for example, you want to show an image 300 pixels high x 300 pixels wide. Then
just call the function and pass it the correct parameters, in this order: filename.jpg,
height, and width.

<a href="javascript:show('mypic.jpg',320,320)">Show me</a>

The added 20 is optional to offset for the default top and left margins of browsers.

now thiiis opens just a new® window evvverytime...'cept shouldnt be tooo hard to just a name® the popup n' have 'em alll go in there...'cept /me thinks tooo??? youd have to have you 'popup' the size of the biggest just a image®...n' have the smaller ones just a center® in it...:O)))

just a goodluck®...


n' whispers to con...
just a getusedtoit® n' love it...tis the nature of just a forums®...hehehe.../me usually just a posts® the link to the 'thread/script' with just a note® to the poster thattt we do have just a wesome® search feature incase one of the pros isnt just a round® to help ya...hehehe...
n' /me didnt post the link to the 'script' in here 'cause /me didnt search.../me remembered she just a had® thattt one from reyn...:O)))

justame
02-02-2003, 08:28 PM
dio...
heres just a nother® one from fpmc...:O))) just a gain® copied/pasted/credited n' saved...:O)))

<Script language="JavaScript">
function openN(URL,winname,ATTR) {
if (window.winN && !winN.closed) winN.location = URL;
else winN = open(URL,winname,ATTR);
winN.focus();
}
</Script>

Instead of using window.open(), one will use:
window.openN(URL, "win", "width=400...")

In the entire page, any links that uses window.openN() will always open in one window.

Just for SonicT. If you want the window always to have the name "win", then

<Script language="JavaScript">
function openN(URL,ATTR) {
if (window.winN && !winN.closed) winN.location = URL;
else winN = open(URL,"win",ATTR);
winN.focus();
}
</Script>

To call it:
window.openN(URL, Attributes)

dionnesimone
02-02-2003, 10:28 PM
I suppose adding that I am a newbie to Javascript doesnt' help either... ...

dionnesimone
02-02-2003, 10:40 PM
Looks like I am getting somewhere now....

beetle
02-02-2003, 10:52 PM
This (http://www.codingforums.com/showthread.php?s=&threadid=9836) does that.