Popup open/close, form submittal, and redirection in one
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?
And to help anyone else out, here's the code I did what I did with:
The initial page code:
<html>
<head>
<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=500,height=500,scrollbars=no');
return false;
}
//-->
</SCRIPT>
</head>
<body>
<a href="popup1.html" onclick="return popup(this, 'notes')">LINK OR BUTTO TO CLICK GOES HERE</a>
</body>
</html>
Then what I put in the popup html file (popup1.html):
<html>
<head>
<SCRIPT TYPE="text/javascript">
<!--
function targetopener(mylink, closeme, closeonly)
{
if (! (window.focus && window.opener))return true;
window.opener.focus();
if (! closeonly)window.opener.location.href=mylink.href;
if (closeme)window.close();
return false;
}
//-->
</SCRIPT>
</head>
<body>
<h3>User Agreement:</h3><br>
This is where I put the entire description of the user agreement. You can add a div and make scrollable boxes here as well if you want to keep it nice and tidy. Mine was short enough there was no need."<br><br>
Bookmarks