View Full Version : How do I make something pop up?
Gayowulf
December 1st, 2001, 04:12
What I need to do is have a page pop up when a submit button is pressed.
I have a poll on my site, and when someone submits their vote it would be more convienient if the results popped up instead of opening in the same window
=THanks.
gyrbo
December 1st, 2001, 04:21
<form action=".......... target="_blank">
Gayowulf
December 1st, 2001, 04:25
can I specify the window size somehow?
meow
December 1st, 2001, 07:49
You need JavaScript. Here's the whole lot. :p
<script type="text/javascript" language="javascript">
<!--
function popper()
{
gaypop = window.open("bleh.html", "gaywin", "height=300,width=200,top=30,left=20,toolbar=1,menubar=1,scro llbars=1,resizable=1,location=1,directories=1,status=1");
}
//-->
</script>
<input type="submit" onclick="popper()">
Or keep it simple. ;)
<input type="submit" onclick="window.open('bleh.html','','height=300,width=200');">
Gayowulf
December 2nd, 2001, 04:38
Thanks, meow.
Now heres another problem: The window pops up fine, but origional page also redirects to the page I want to pop up. Is there anyway to stop this?
gyrbo
December 2nd, 2001, 06:01
<script type="text/javascript" language="javascript">
<!--
function popper()
{
gaypop = window.open("bleh.html", "gaywin", "height=300,width=200,top=30,left=20,toolbar=1,menubar=1,scro llbars=1,resizable=1,location=1,directories=1,status=1");
}
//-->
</script>
<input type="submit" onclick="popper();return false;">
Dusty
December 2nd, 2001, 11:59
...not that the others didn't work, but mine's better ;):
<form action="/cgi-bin/poll.pl" target="poll_window">
<input type="submit" onClick="window.open('','poll_window','height=300,width=200');return true;">
</form>
This way the form actually loads in the popup, unlike the static pages that the other's scripts were loading, and the form still opens in a new window (albeit just a regular browser window) even if JavaScript is disabled.
gyrbo
December 2nd, 2001, 12:46
Have you tested that code? When I tried that, It opened two windows.
[edit]
heck, it works! I don't know what I did wrong all the time...
Gayowulf
December 2nd, 2001, 15:48
Thanks for both methods. :) My site is really starting to get good now ;)
Gayowulf
December 2nd, 2001, 16:10
I spoke too soon :eek:
The window pops up fine, but nothing loads.
what now?
Dusty
December 2nd, 2001, 16:12
Which script?
Gayowulf
December 2nd, 2001, 16:19
The script you mentioned
Dusty
December 2nd, 2001, 16:23
Works fine for me, in both Netscape and IE.
What I've been testing:
<form action="http://www.freewebspace.net/forums/" method="get" target="poll_window">
<input type="submit" onClick="window.open('','poll_window','height=300,width=200');return true;">
</form>
Gayowulf
December 2nd, 2001, 16:30
Could the problem be that
<form action="/mailist/maillist.php" target="poll_window">
and
<input type="submit" onClick="window.open('','poll_window','height=300,width=200');return true;" name="submit" style="font-family: Arial; font-size: 8pt; background-color: #b80000; color: #000000; font-weight: regular;" value="Submit">
appear about 15 lines apart?
Dusty
December 2nd, 2001, 16:54
No, that's not the problem. I answered it in your other thread, http://www.freewebspace.net/forums/showthread.php?postid=135483#post135483
Gayowulf
December 2nd, 2001, 16:57
Yeah.
Thanks again, Dusty :)
meow
December 2nd, 2001, 17:42
Do I understand this right? If one leaves the URL bit in the js blank, it's taken from the action or href in the tag it's in?:confused:
I never new that. :)
Gayowulf
December 2nd, 2001, 17:53
I'm still having heaps of trouble.
I just cant get these forms to work right:mad:
what should I do? Dusty, youve seen the source...
Dusty
December 2nd, 2001, 21:22
Similar problem. Actually, more than just similiar, it's the same problem. ;)
Here's your HTML now:
<form method="post" action="/poll/vote.php" target="poll_window">
</form><p align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">If there was a forum (BBS) here would you use it? </font></b></p>
<input type="radio" name="answer" value="1"><b><font color="#FFFFFF" size="1">Yes</font></b><br>
<input type="radio" name="answer" value="2"><b><font size="1"> No</font></b><br>
<input type="radio" name="answer" value="3"><font size="1"> <b>It depends...</b></font><br>
<input type="hidden" name="save" value="yes">
<p align="center"><input type="submit" onClick="window.open('','poll_window','height=300,width=200');return true;" name="submit2" style="font-family: Arial; font-size: 8pt; background-color: #b80000; color: #000000; font-weight: regular;" value="Vote!"></p>There are two problems. The first is that the form is closed right after it's opened, which makes it of no use to the poll. The second is that the form isn't closed after the poll, which means simply removing the </form> wont solve it. You need to change it to this:
<form method="post" action="/poll/vote.php" target="poll_window">
<p align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">If there was a forum (BBS) here would you use it? </font></b></p>
<input type="radio" name="answer" value="1"><b><font color="#FFFFFF" size="1">Yes</font></b><br>
<input type="radio" name="answer" value="2"><b><font size="1"> No</font></b><br>
<input type="radio" name="answer" value="3"><font size="1"> <b>It depends...</b></font><br>
<input type="hidden" name="save" value="yes">
<p align="center"><input type="submit" onClick="window.open('','poll_window','height=300,width=200');return true;" name="submit2" style="font-family: Arial; font-size: 8pt; background-color: #b80000; color: #000000; font-weight: regular;" value="Vote!"></p>
</form>
Dusty
December 2nd, 2001, 21:25
Do I understand this right? If one leaves the URL bit in the js blank, it's taken from the action or href in the tag it's in? I never new that.No, you don't understand that right :D. Actually, anything could be there. Leaving it blank just means you only want a window opened, no page. It's the "return true" bit that passes it on to the action and href.
Gayowulf
December 3rd, 2001, 00:55
Thanks again, Dusty, but it still doesnt work right. It popus ip 2 windows. The small one and then a big, fullsize one.
meow
December 3rd, 2001, 01:29
Originally posted by Dusty
No, you don't understand that right :D. Actually, anything could be there. Leaving it blank just means you only want a window opened, no page. It's the "return true" bit that passes it on to the action and href.
But then HTF does the poll result get into the pop-up window? :confused:
Dusty
December 3rd, 2001, 14:12
Thanks again, Dusty, but it still doesnt work right. It popus ip 2 windows. The small one and then a big, fullsize one.You haven't fixed it on your website yet so I can't try it there but it's working fine on my test page.
But then HTF does the poll result get into the pop-up window?Think of it as a frame. The popup, like a frame, has a name. It's name is "poll_window", as is defined by "window.open('','poll_window'...". The form is targeted to the frame "poll_window" which happens to be the popup. That's why the form loads in it.
meow
December 3rd, 2001, 15:14
Sorry, didn't see the target. I would have thought something more subtle was needed.
Gayowulf
December 4th, 2001, 01:00
Originally posted by Dusty
[B]You haven't fixed it on your website yet so I can't try it there but it's working fine on my test page.[B]
Its updated now
Dusty
December 4th, 2001, 14:39
It works for me. The script doesn't, it gives an error, but it does open in the popup.
Gayowulf
December 4th, 2001, 20:26
Ok. must be something on my end then. I've got 3 other people saying it works for them too.
I get 2 popups one big, one small.
oh well as long as they see it ok.
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.