View Full Version : Need help with a form! Need to close parent window on redirect.
aquatopia_mazza402
02-20-2006, 08:09 PM
I haven't done JavaScript in such a long time. I have a [FORM] button that when clicked on, redirects to a webpage. I need it to close the parent window after they click on the button.
When they visit my site, if they are a guest, they are greeted with a popup. If members want to log in, they click on the log in button. It redirects to the webpage great, but it leaves the original window up. What can I put in my code to get it to close that window out?
Heres the code that I have.
<form>
<input type="button" value="Log In"
onclick="window.open('http://aquatopiaforum.com/index.php?act=Login&CODE=00')">
</form>
Thanks in advance!
onclick="window.open('http://aquatopiaforum.com/index.php?act=Login&CODE=00');window.close();"... maybe?
You need to always provide a normal HTML form submission as a backup. In your case, you'd do something like this:
<form target="_blank" action="/index.php" method="get">
<input type="hidden" name="act" value="Login" />
<input type="hidden" name="CODE" value="00" />
<input type="submit" value="Log In" onclick="window.close();" />
</form>Add whatever Javascript you need on top of that, but make sure it works without Javascript too.
aquatopia_mazza402
02-20-2006, 09:00 PM
Heres the code for the 'splash screen.'
Thanks for the info.
Not sure exactly where to put my website so it will direct though. Like I said, it's been awhile. :eek:
<form target="_blank" action="/index.php" method="get">
<input type="hidden" name="act" value="Login" />
<input type="hidden" name="CODE" value="00" />
<input type="submit" value="Log In" onclick="window.close();" />
</form>
<html>
<body bgcolor="0066cc" onLoad="if (self != top) top.location = self.location">
<IMG SRC="F:/HTML/aquabanner.png" ALT="AquaTopiaForum.com">
<br>
<br>
<TABLE BORDER CELLSPACING=0 BORDERCOLOR="000000" WIDTH=60% RULES=GROUPS FRAME=BOX>
<TR>
<TH COLSPAN=2 BGCOLOR="#99FFFF">Welcome, Guest!</TH>
</TR>
<TR> <TD BGCOLOR="#FFFFFF"><IMG SRC="F:/mazzaavatar.png" ALT="MAZZATAR" ALIGN=LEFT></TD>
<TD BGCOLOR="#FFFFFF">
<BR>
<P><B>I see that you haven't registered yet.</B></P>
<P>As a registered member, you will enjoy all of the following benefits:
<UL>
<LI><I>The ability to post in most forums.</I>
<LI><I>You will be able to visit the member map.</I>
<LI><I>You will no longer have to view google ads.</I>
<LI><I>You will have the opportunity to earn AquaToken rewards.</I>
<LI><I>Most importantly you won't see this little pop-up!</I>
</UL>
<P>Registration is <I>fast</I> and <I>easy.</I></P>
<P>You have nothing to lose and everything to gain by joining our growing community of Aquarium hobbyists!</P>
</TD>
<TR> <TD BGCOLOR="#FFFFFF"></TD>
<TD BGCOLOR="#FFFFFF">
<form>
<input type="button" value="Register"
onclick="window.open('http://aquatopiaforum.com/index.php?act=Reg&CODE=00')">
</form>
</P>
<HR = 1>
<TR> <TD BGCOLOR="#FFFFFF"></TD>
<TD BGCOLOR="#FFFFFF">
<BR>
<P>Already a registered member of AquaTopiaForum.com?</P>
<TR>
<TD BGCOLOR="#FFFFFF"></TD>
<TD BGCOLOR="#FFFFFF">
<form>
<input type="button" value="Log In"
onclick="window.open('http://aquatopiaforum.com/index.php?act=Login&CODE=00')">
<form method="post">
<input type="button" value="Later"
onclick="window.close()">
</form>
</TABLE>
</HTML>
aquatopia_mazza402
02-20-2006, 09:05 PM
Actually, instead of pointing to the same site, I actually need it to point to www.aquatopiaforum.com/index.php.
It's pointing to our free webspace instead of our forum. Any idea what I can change _blank to?
Thanks for the quick reply!
<html>
<body style="background-color:#0066cc;" onload="if (self != top) top.location = self.location">
<IMG SRC="F:/HTML/aquabanner.png" ALT="AquaTopiaForum.com">
<br>
<br>
<TABLE BORDER CELLSPACING=0 BORDERCOLOR="000000" WIDTH=60% RULES=GROUPS FRAME=BOX>
<TR>
<TH COLSPAN=2 BGCOLOR="#99FFFF">Welcome, Guest!</TH>
</TR>
<TR> <TD BGCOLOR="#FFFFFF"><IMG SRC="F:/mazzaavatar.png" ALT="MAZZATAR" ALIGN=LEFT></TD>
<TD BGCOLOR="#FFFFFF">
<BR>
<P><B>I see that you haven't registered yet.</B></P>
<P>As a registered member, you will enjoy all of the following benefits:
<UL>
<LI><I>The ability to post in most forums.</I>
<LI><I>You will be able to visit the member map.</I>
<LI><I>You will no longer have to view google ads.</I>
<LI><I>You will have the opportunity to earn AquaToken rewards.</I>
<LI><I>Most importantly you won't see this little pop-up!</I>
</UL>
<P>Registration is <I>fast</I> and <I>easy.</I></P>
<P>You have nothing to lose and everything to gain by joining our growing community of Aquarium hobbyists!</P>
</TD>
<TR> <TD BGCOLOR="#FFFFFF"></TD>
<TD BGCOLOR="#FFFFFF">
<form target="_blank" action="/index.php" method="get">
<input type="hidden" name="act" value="Reg" />
<input type="hidden" name="CODE" value="00" />
<input type="submit" value="Log In" onclick="window.opener.close();" />
</form>
</P>
<HR = 1>
<TR> <TD BGCOLOR="#FFFFFF"></TD>
<TD BGCOLOR="#FFFFFF">
<BR>
<P>Already a registered member of AquaTopiaForum.com?</P>
<TR>
<TD BGCOLOR="#FFFFFF"></TD>
<TD BGCOLOR="#FFFFFF">
<form target="_blank" action="/index.php" method="get">
<input type="hidden" name="act" value="Login" />
<input type="hidden" name="CODE" value="00" />
<input type="submit" value="Log In" onclick="window.opener.close();" />
</form>
<button onclick="window.close();">Later</button>
</table>
</html>I've applied the code. I started hacking away at your HTML errors, too, but there are too many for one sitting: I suggest you run it through a validator (http://validator.w3.org/).
aquatopia_mazza402
02-20-2006, 09:14 PM
Will do. Any way to get it to direct to aquatopiaforum.com instead of _blank and /index.php?
I need it to point to our forum login page.
I'll run it through a validator as soon as I get a chance. Thanks for the tip.
Presuming your index.php page is located at http://www.aquatopiaforum.com/index.php, and that page is on the same domain, it will redirect to it.
aquatopia_mazza402
02-20-2006, 10:56 PM
It's actually not on the same domain though, thats the problem I am running into. It's a geocities website that we are using for the splash page, and that is pointing to our domain.
Ah, OK. In that case, just replace /index.php with the full URL to your index.php, as you did earlier.
aquatopia_mazza402
02-21-2006, 05:40 PM
Sounds good. I'll give that a try. Thanks a bunch for the help.
So it's _blank and then replace index.php with the full URL?
For some reason I think I gave that a try and it actually tried to put it as www.geocities.com/www.aquatopiaforum.com/index.php.
Am I doing something wrong?
Try including the protocol.
aquatopia_mazza402
02-21-2006, 06:33 PM
Forgive me for asking but.... protocol?
Also, you mentioned my HTML code was a security nightmare. Too many errors to mention.. Remember what any of them we're so that I can correct them? I know my HTML is fairly basic. Only enough time to sketch out a general design and get it operational has been spent.
Also, you mentioned my HTML code was a security nightmare.No, a potential compatibility nightmare :p Paste it into the validator (http://validator.w3.org/) to see some of the errors.
aquatopia_mazza402
02-21-2006, 06:54 PM
Ahhh... compatibility, lol. I know exactly what you mean.
protocol?The structure of data sent over the network, shown in a URI by the protocol name followed by a colon and two forward slashes; in this case, probably http:// or https://.
aquatopia_mazza402
02-21-2006, 07:06 PM
Sounds good. I'll give it a try. Thanks a bunch for all the help!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.