Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close and Redirect to Other Page 2

Status
Not open for further replies.

DBSJeff

Programmer
May 18, 2002
4
0
0
US
The code below (probably primative and inefficient) opens a pop-up box, shows brief text and two buttons. One button is supposed to close the box and redirect the viewer to another page on the website. The other button simply closes the box.

As written, when the "download" button is pressed, the redirected page comes up in the box. The close button works correctly.

Would very much appreciate a solution to close and redirect. Also, suggestions for more efficient code for the entire box are welcome.

Thanks - Jeff

<TABLE WIDTH=&quot;400&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot; BORDER=&quot;0&quot;>
<TR><TD ALIGN=&quot;CENTER&quot;><FONT FACE=&quot;Arial,Helvetica&quot; color=&quot;WHITE&quot; size=+1><STRONG>Be sure to download our Internet Coupon for instant savings when you place your order with us.<BR><BR>This is our way of thanking you for visiting our website.</STRONG></CENTER></TD></TR>
</TABLE>
<BR>
<TABLE WIDTH=&quot;400&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot; BORDER=&quot;0&quot;>
<TR ALIGN=&quot;CENTER&quot;>
<TD><FORM METHOD=&quot;GET&quot; ACTION=&quot;javascript:window.location='<INPUT TYPE=&quot;SUBMIT&quot; NAME=&quot;BUTTON1&quot; VALUE=&quot;Download&quot;>
</FORM></TD>
<TD><FORM METHOD=&quot;GET&quot; ACTION=&quot;javascript:window.close()&quot;>
<INPUT TYPE=&quot;SUBMIT&quot; NAME=&quot;BUTTON2&quot; VALUE=&quot;No Thanks&quot;>
</FORM></TD>
</TR></TABLE>
 
If I understand what you are trying to do, you want the download button to change the page in the window that opened the pop up box.If so the following should work, I tried to clean it up a little for you but I don't have time to check it


<html>
<head>
<script language=&quot;javascript&quot;>
<!--
function download()
{
window.opener.location.replace(&quot;window.close(&quot;popUpWindow.html&quot;);
}

//-->
</script>
</head>
<body>
<div style=&quot;width:400px;font-size:16pt;text:align:center;&quot;>
<p>
<font face=&quot;Arial,Helvetica&quot;><b>Be sure to download our Internet Coupon for instant savings when you place your order with us.<br><br>This is our way of thanking you for visiting our website.
</b>
</font>
</p>
</div>
<br>
<table width=&quot;400&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot;>
<tr align=&quot;CENTER&quot;>
<td>
<form>
<input type=&quot;button&quot; name=&quot;BUTTON1&quot; value=&quot;Download&quot; onclick=&quot;download()&quot;>
</form>
</td>
<td>
<form>
<input type=&quot;button&quot; name=&quot;BUTTON2&quot; value=&quot;No Thanks&quot; onclick=&quot;window.close()&quot;>
</form>
</td>
</tr>

</table>
</body>
</html>

I'm not sure if it'll work, but give it a try.
 
Sorry, but it did not work. I really appreciate your time
and effort. I tried to diagnose your script and follow what was going on, but don't yet have the expertise to tweak and make work. Thanks again.
 
hi,
Code:
window.opener.location.replace(&quot;[URL unfurl="true"]http://www.dbs-discount.com/dbs/coupon.htm&quot;;);[/URL]
should be:
Code:
window.opener.location.replace(&quot;[URL unfurl="true"]http://www.dbs-discount.com/dbs/coupon.htm&quot;);[/URL]
I checked it, and it works for me, make sure you put the file name of your pop up window here

window.close(&quot;popUpWindow.html&quot;);

let me know if it works for you
 
I think we're getting there, not that your original script wasn't close. When I make the corrections as noted, I get an error message &quot;'window.opener.location' is null or not an object.&quot;

Any further thoughts?
 
Can you show me how you're openeing the popUpWindow? I tried finding it on your site, but with no luck. It worked for me in IE 5.5 Netscape 4.7 Netscape 6 and Opera 5 using the following basic page to open the window.
Code:
<html>
<head>
<script language=&quot;javascript&quot;>
</script>
</head>
<body>
<form>
<input type=&quot;button&quot; value=&quot;click here!&quot; onclick=&quot;window.open('popUpWindow.html','couponpage','width=600, height=500')&quot;>
</form>
Here is the first page
</body>
</html>
[\code]

Let me know if this helps.

dis
 
That made it fly. Thanks so very much for your time!
 
Good job dislimbic!! [thumbsup] É

endamcg-logo1b.gif

 
Working with windows is always a pain for me so I avoid them 99.99% of the time. It's good to have people dive into windows like dislimbic that is why I reward him with a second star.

Good job. Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top