Forum Moderators: mack

Message Too Old, No Replies

multiple popup windows

multiple popup windows

         

crizlunati

7:34 pm on Nov 19, 2003 (gmt 0)

10+ Year Member


I have a jewelry site with over 100 items. My website is done in flash and the items are shown as thumbnails. The goal is when you click on them the enlargement shows up as a popup. Here is the code I tried to use:
IN THE FLASH MOVIE:

on (release) {
getURL("JavaScript:popup();");
}

IN THE HTML PAGE:

<SCRIPT LANGUAGE="JavaScript">
function popup() {
window.open('item1.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=475,height=625,left=50,top=50');
}
</script>

Now this works for item1.html, but the problem lies if I want another popup of lets say, item2.html. I entered the same code again in the HTML PAGE (that holds the movies) that looked like this:

<SCRIPT LANGUAGE="JavaScript">
function popup() {
window.open('item1.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=475,height=625,left=50,top=50');
}
</script>
<SCRIPT LANGUAGE="JavaScript">
function popup() {
window.open('item2.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=475,height=625,left=50,top=50');
}
</script>

Now I have one for item1.html and item2.html.
Problem is that now all buttons only open item2.html
what am i doing wrong? and what about me having over 100 items? anyways to do this with variables so that one <script></script> code is needed for all of them? or is their a better way to do this?
please help. thank you.

criz lunati

korkus2000

11:42 pm on Nov 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the board crizlunati,

You have the same name for your functions. You need to have something more dynamic. You need to pass a parameter to one function that sets the destination page like:

on (release) {
getURL("JavaScript:popup('item1.html');");
}

Then use it in your function like:

<SCRIPT LANGUAGE="JavaScript">
function popup(destination) {
window.open(destination,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=475,height=625,left=50,top=50');
}
</script>

If you want to use the same popup window the add a name to your window as the second parameter of the window.open method.

I have not tested this code so it may need some tweeking.

crizlunati

1:59 pm on Nov 20, 2003 (gmt 0)

10+ Year Member



error posting...sorry

[edited by: crizlunati at 2:01 pm (utc) on Nov. 20, 2003]

crizlunati

2:00 pm on Nov 20, 2003 (gmt 0)

10+ Year Member



Hi! Thank you very much for responding. I apologize but I'm a newbie at this. I don't really understand what you mean. I copied this code from Flashkit.com.

Is the variable 'destination'? So that whenever I click on any item, for example 'item1' it will plug item1.html into 'destination' and show the popup enlargement of item1?

crizlunati

2:10 pm on Nov 20, 2003 (gmt 0)

10+ Year Member



THANK YOU! it works! how? I don't know. I would love to understand... If you have the chance. Please explain. Your the bomb. Thanks

criz lunati

korkus2000

2:24 pm on Nov 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



on (release) {
getURL("JavaScript:popup('item1.html');");
}

In this code you are telling the browser to use javascript instead of finding a new page using the javascript protocal(JavaScript:). Then you are telling it which function to use (popup()). We are going to pass the name of the page you want to open, which is 'item1.html' in this case. You just populate the name of the page you want there for the click.

function popup(destination) {
window.open(destination,'', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=475, height=625, left=50, top=50');
}

Now we are telling the function to expect a parameter with the call. If you were to call popup() without a string inside the parenthasis you would get an error. We need to name it something so I just named it destination, since basically thats what it is.

Next we are going to take your original window.open method. This method takes 3 parameters, just like our popup function takes 1, destination. The first is the name of the html to open in the popup. We put destination here which is a variable and holds the value we passed in the original call, 'item1.html'. A side note is that we used quotes to surround the name because it is of a data typr string. A string is basically words and text compared to an integer or a date.

Next we need a name for the popup. As you can see from the original code that you don't have to pass anything. If you want to have control over it and have other things open in it, then you should put some string(name) in there. The last as you can see just gives you all kinds of properties of the window you are opening.

Glad to see it worked. If you are interested in learning Javascript then you can read our jumpstarts:
[webmasterworld.com...]

Welcome to WebmasterWorld!