View Full Version : Muliple popup problems
skwerl mastah
07-16-2002, 05:36 PM
I realize this may be an incredibly simple question to be answered, but I'm about as new as it gets with Javascript. That and I'm too determined to do it how I'm envisioning it.
I have an index page with several text links to different .html doc's, and I'm using a popup script to open them up in a seperate window without all of the clutter (i.e the toolbar and address bars, among others). Problem is, I've set up all the links, but every single link - from the first one all the way down the line - all go to the last site I've entered to be a popup.
The solution I'm wanting is simple: I just want each link to follow through to each own's according link, not the last one.
tamienne
07-16-2002, 06:08 PM
So are you saying you want a different popup for each link?
<A HREF="url" onClick="popUpWindow('aname',this.href);return false;">xyz</A>
function popUpWindow(pname,theURL) {
window.open(theURL,pname);
}
For each link you have, change 'aname' to something different.
You could make it always popup a new window by adding a random number generator into the function.
premshree
07-16-2002, 06:08 PM
To open a link in a pop-up :
<a href="javascript:void(0);" onClick="window.open('fileName.htm', 'Title', 'width=400, height=400, toolbar=no, statusbar=no');">Click</a>
If this is not what you want, could you send the code you are using.?
Tutorial (http://fitale.com/diamond.php?page=snippets&howto=popup) -
on passing variables into popup window functions.
skwerl mastah
07-17-2002, 01:48 AM
I'm using this code:
<script>
function openpopup(){
var popurl="thankyou.htm"
winpops=window.open(popurl,"","width=400,height=338,")
}
</script>
<a href="javascript:openpopup()">Click</a>
I'm sure I'm missing something. i.e. different names for each script, but I'm lost on what and where.
So if I wanted to put, say index.html and main.html and name them index and main in the code respectively, what would I do? Is this the correct code?
whammy
07-17-2002, 02:39 AM
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
function openpopup(URL){
winpops=window.open(URL,"","width=400,height=338,")
}
// -->
</script>
</head>
<body>
<a href="javascript:openpopup('http://www.yahoo.com')">Yahoo!</a><br />
<a href="javascript:openpopup('http://www.google.com')">Google</a>
</body>
</html>
P.S. If you read the tutorial that Okii posted (highly recommended) you'd know that "URL" is the variable I'm passing to the javascript function from HTML. :)
premshree
07-17-2002, 03:48 AM
Well Whammy, yes it is better to use a more generic script but I don't find anything wrong in the post above yours. Do you?
whammy
07-17-2002, 02:22 PM
Sure, it doesn't pass any variables into the function, which is what he needs to do - so he doesn't need to write the same function over and over again with "different names", all he has to do is pass a different URL to the function.
Notice the slight difference:
openpopup(URL)
I just slightly rewrote the function in the post above mine to illustrate this. OK?
skwerl mastah
07-21-2002, 10:58 AM
Well whammy, it worked for me. Thanks. As I stated before, I'm pretty fresh on Javascript, but hopefully I can figure out this stuff eventually. Thanks again for everyone's help.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.