-
Functions & window popup
I have a number of windows that i want to open up in a seperate window, and i have tried the following code
<script language="javascript">
//<!--
function popup(a url)
{ window.open ("a url","Comments","width=500,height=400,location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0") }
//-->
</script>
with the link being <a href="javascript:popup(example.html)">
as you can see, Im a complete newbie to JavaScript
when i click on the link, nothing pops up and nothing happens. there is the little error on page status bar message, so i guess its something to do with my code....
-
The problem probably lies with a url. Try it with just url.
G
-
hmmm, well ive changed it now.
I use it in a poll script, and this is the exact code that i have written.
<script language="javascript">
//<!--
function popup(url)
{ window.open ("url","Comments","width=500,height=400,location=1,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0") }
//-->
</script>
and the link is
<a href="javascript:popup('[%scriptname%]?poll=[%pollid%]&viewcomments=1')">Comments</a>
the script name and pollid are variables in the poll. When i click on the popup, i get a window with the url http://thegaffer.neopages.net/url instead of http://thegaffer.neopages.net/[%scriptname%]?poll=[%pollid%]&viewcomments=1 with the variables obviuosly replaced with their values
whats wrong? u can try for yourself at http://thegaffer.neopages.net/index2.shtml, and click on the Poll comments.
-
Whoops! Ignore that ... interesting.
G
-
whats wrong is that instead of taking the value of "url" it just puts the text url in the url...
eg thegaffer.neopages.net/url
instead of (and lets say url=test.html)
thegaffer.neopages.net/test.html
-
The JavaScript isn't at fault. The server-side stuff is returning the URL /cgi-bin/poll/poll.cgi?poll=000003&viewcomments=1 whereas it should be (and I checked) cgi-bin/poll/poll.cgi?poll=000003&viewcomments=1. The problem is that the Perl, [%scriptname%], is giving you an unwanted forward slash at the start of your URL. May I suggest that you throw this part in manually since it won't change, ie:
<a href="javascript: popup('cgi-bin/poll/poll.cgi?poll=[%pollid%]&viewcomments=1')">Comments</a>
:)
-
nope :( still doesnt work
-
Well manually typing in that URL worked ....
:confused: