Forum Moderators: open
i am trying to set things so that when a certain page loads, a window pops open with legal terms and conditions. The user must hit a button, Accept (and be allowed through) or Decline and be redirected back to the home page. The legal department wants to make sure everyone has to see this alert before they may proceed.
Does anyone have any ideas. I am not really a Javascript writer.
The legal department wants to make sure everyone has to see this alert before they may proceed.
As (client-side) javascript can be (and often is) easily turned off 'by default', it is highly probable that some of your visitors would never see such a pop-up
Bearing in mind that your requirements are being driven by your legal department, it is perhaps worth noting that there are various regulations in many countries covering accessibility [google.com], so the use of <noscript> tags is unlikely to be a satisfactory workaround
Instead, I think, you'll need a server-side solution... perhaps something along the lines of the advice given on your thread entilted "What method should I use to restrict access to sections of my website? [webmasterworld.com]"
In the meantime, I would like to put something up. Just a little something.
I found this code but it says it is LiveScript which must mean it is old!
<SCRIPT LANGUAGE="LiveScript">
<!--
function checkAGE(){
if (!confirm
("(Much leagal speak and warnigs and such. )"))
history.go(-1);return ""}
document.writeln(checkAGE())
<!--End-->
</SCRIPT>
I like the way this works but I have three questions.
1.Is this so old that I will have a problem with it's functionality?
2. The buttons say "OK" and "Cancel". Is there a way to change what they say to "Accept" and "Decline"?
3. The top of the message box reads "The page at www.example.com" read:
Is there a way to change that?
To simplify this, you would move my inline solution here to an external Javascript file so you don't have to code in every page that has the link.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype on one line -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TOS required</title>
<script type="text/javascript">
function newWin(url) {
var day = new Date();
var id=day.getTime();
var params = 'width=400,height=400,scrollbars,resizable';
var win=open(url,id,params);
win.document.close();
return false;
}
</script>
</head>
<body>
<p><a href="#" onClick="return newWin();">Go to Page</a></p>
</body>
</html>
But now we have a new problem, navigating to the actual page. In "tos.html" you would want to do the following. The page that opens the pop up is the window.opener:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype on one line -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TOS</title>
<script type="text/javascript">
window.onunload=function () { if (window.opener) { window.opener.location='the_page.html'; } }
</script>
</head>
<body>
<p>Blah blah blah, I hereby agree to not steal from the company,
not say bad stuff about the boss, and always put the toilet seat down.</p>
<form><input type="button" onClick="window.close();" value="OK, I Agree"></form>
</body>
</html>
Where "the_page.html" is your protected page. Note that this works for both the button and "X" ing the page.
This only works on first visit. Thereafter they can bookmark it, which I'm guessing is not a problem. If they go to "the_page.html" directly somehow, what you could do is set a cookie in the code of the popup window (TOS_OK=1). Then on the_page.html have Javascript that checks for the cookie, if it's not present, sent them back a page.
What control do employees have over their browser settings?
All of this makes a difference as far as what approach and fall-back approach to take.
I've noticed lately when requesting certain downloads from Microsoft's MSDN site that I first get a "DHTML" popup where I have to click I AGREE before the download will begin.
They are using a "cover div" that puts a gray veil over all the content on the page and then, on top of that, in the center of the page is the popup box with the licensing info and the buttons.
The advantage to this approach is that pop-up blocking won't affect it. If, however, javascript is disabled (unlikely, but possible) it won't work.
Have fun:)
puts a gray veil over all the content on the page and then, on top of that . . . .
. . . Annoys me to no end. :-) I HATE those things. Plesk has them, nothing like waiting for Javascript to finish loading all the pretty graphics over an https connection to follow the one link you need. It's just annoying to be forced to do something in ordinary navigation.
</rant> However, in this case it would probably apply. As you were! :-)