Jump to content

how do i use "function open_win()" more than once on a page?


willeyeam

Recommended Posts

Thanks in advanceI'm learning here, so bear with me. . .I'm using the "function open_win()" to have a button pop-up for a .swf to play in.I got it working, thanks to w3schools.However, i wish to have more than one of these on the page, each going to a different address.I do not see how to reuse that function in multiple buttons, without them all going to the same address.there must be some way to identify each function so that different buttons can refer to them individually, or some thing.here's the code i'm using

<script type="text/javascript"> function open_win() { window.open("http://67.40.250.86/~Willeyeam/Final.swf","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, titlebar=no, resizable=no, copyhistory=no, width=390, height=720,") } </script>

and the form/button

<input type="button" value="enter, never to escape" onclick="open_win()"></form>

so i'd like to make other buttons that have a different value (what is now the other two href's) and refer to different scripts (pointing to different pages.)check out my site, it's hosted on my cpu. (btw, is this unsafe to do? using the OSX apache thing?)check itthe links I want to turn into popup buttons are at the bottom of the table.its not much, "under development" is my excuse! it's my first site, really.Part 2I would rather use a thumbnail image instead of a button. how can I do that as a popup, and still maintain control of the new window?

Link to comment
Share on other sites

I think you are looking for something like this:

<script type="text/javascript">function open_win(url, name, width, height){	var windowProps = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,";	windowProps += "titlebar=no,resizable=no,copyhistory=no,width=" + width + ",height=" + height;	window.open(url,name,windowProps);}</script>

and this could be how you call it:

<a href="http://67.40.250.86/~Willeyeam/Final.swf" target="_swfs" onclick="open_win('','_swfs',390,720);"><img src="thumbnail.gif" alt="TheThumbnail" /></a>

I hope it helps!

Link to comment
Share on other sites

First of all, yea Portland. . .

and this could be how you call it:
<a href="http://67.40.250.86/~Willeyeam/Final.swf" target="_swfs" onclick="open_win('','_swfs',390,720);"><img src="thumbnail.gif" alt="TheThumbnail" /></a>

I hope it helps!

Wow! Thanks. I guess there is a lot to javascript that you won't learn on the W3schools site (in the ten miutes i usually look there until i find the answer). (I did look for an hour or so on this one). I think I understand from examination what this code does, all excepts for the;
target="_swfs"

and the ',_swfs' in;

('','_swfs',390,720)

does that tell the browser that a flash .swf file is to be opened? Or is that just a coincidence and I have no idea what that's for.W3schools doesn't have this on their site, so please tell me, eh?ThanksWill

Link to comment
Share on other sites

yea Portland. . .
YEA!
I think I understand from examination what this code does, all excepts for the;
target="_swfs"

and the ',_swfs' in;

('','_swfs',390,720)

does that tell the browser that a flash .swf file is to be opened? Or is that just a coincidence and I have no idea what that's for.

It is the name of the window. You could name your popup window whatever you want, I just chose "_swfs" because you happened to be using it to open your swf files. You could name it "MyWindowFromPDX" if you wanted.Then it'd look like: open_win('','MyWindowFromPDX',390,720);The target is telling the browser where to open the URL. Since we named the window "_swfs" (or "MyWindowFromPDX") then we specify target="_swfs" (or target="MyWindowFromPDX").Does that clear it up?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...