I'm wondering if you can create javascript all in one command for a popup window to open and close and other things, instead of splitting the code up into the first html and the popup window's html code it loads.

This is what I'm trying to do:

1) User clicks a link that opens a popup window
2) They click a check box under an agreement form and click "I agree"
3) Which then closes the popup window and redirects them to a url offsite

I have done this successfully by splitting the code, where one piece opens the window which loads an html file in that window, then that html file contains javascript which closes the window and redirects them.

The problem with this I found out, is that the page I redirect them to, is another website, that when the user clicks a link "return to ______ website", they end up getting redirected back to the url of the html page (agreement text) loaded in the popup window, not the website! Not good.

So the solution I'm thinking, would be to do everything in one html code??? Or will that not work? Any other solutions/ideas?