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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help modifying this code to display on window exit... Thanks

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt]

hello all, I have a form which is being submitted and immediatelly redirects to my default page.
I would like to display a "Thanks.asp" page after the re-direct.
How can I modify this code to trigger after the re-direct?


<script language=&quot;JavaScript&quot;>
<!--

function win_open() {
window.open('Thanks.asp','','toolbar=no,directories=no,status=no, scrollbar=no, width=320,height=320,left = 220, top =220');
}

function now() {

setTimeout(&quot;win_open()&quot;, 2000);

}

now();

//-->
</script>

Thanks in advance...



Delete * from brain Where MaxLevel = &quot;Full&quot; and reaction = &quot;Slow&quot; order by StartOver
 
How about <body onload=&quot;now()&quot;> in the window of the redirect?
 
Sorry typed too fast...

How about having a cookie whose value reflects whether or not your form has been submitted. If it has, &quot;now()&quot; executes. If the form has not been submitted, now() does not execute?
 
[tt]Tho I use cookies throughout the site greedyzebra, this is simply for my clients that request new info, and I rather display the popup after the redirect.

Adding the <body onload=&quot;now()&quot;> on my redirect page will promp the window everytime anyone visits the site.



Delete * from brain Where MaxLevel = &quot;Full&quot; and reaction = &quot;Slow&quot; order by StartOver
 
>>Adding the <body onload=&quot;now()&quot;> on my redirect page will promp the window everytime anyone visits the site.

Yeah. That's why I said I typed too soon :)

Is there any reason you can't call the popup after submission of the form, then redirect?

If you wanted it to appear shortly after redirect, perhaps you could use setTimeout() to delay its appearance.

Don't know if I'm helping here...
 
One last suggestion.

Perhaps you could look at the document.referrer value to see if you wish to execute &quot;now().&quot; I can't really test to be sure since what I'm working with is not a published page on the web, but that value should always reflect the URL of the page just visited.

Maybe upon form submission you could redirect to a page with no content (short load time, so the user would probably never even see it); that page then redirects to your default page. If the value of document.referrer == the URL of the no content page that will only be visited when a form is successfully submitted, you can execute &quot;now().&quot;

Hope that makes sense.
 
[tt]Yes it does. I'm also testing a few other options at the moment. Thanks for your response greedyzebra.



Delete * from brain Where MaxLevel = &quot;Full&quot; and reaction = &quot;Slow&quot; order by StartOver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top