<!-- DOCTYPE может быть другим, но он должен быть -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<!--
https://github.com/carhartl/jquery-cookie -->
<script src="jquery.cookie.js"></script>
<!--
http://fancybox.net -->
<script src="fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" href="fancybox/jquery.fancybox-1.3.4.css" />
<script>
jQuery(document).ready(function () {
jQuery('#hidden_link').fancybox({
'titleShow' : false,
'modal': true,
'overlayOpacity' : 0.5
});
if(!checkAge()) {
jQuery('#hidden_link').trigger('click');
}
});
function accept() {
jQuery.cookie('age', 18, {expires:1});
jQuery.fancybox.close();
return false;
}
function cancel() {
window.location = 'http://google.com';
}
function checkAge() {
return (jQuery.cookie('age') == 18);
}
</script>
</head>
<body>
<a id="hidden_link" style="display: none;" rel="fancybox" href="#checkAge"></a>
<div style="display: none;">
<div id="checkAge">
<h1>18+</h1>
<p>
<button id="age-accept" onclick="accept();">Yes</button>
<button id="age-cancel" onclick="cancel();">No</button>
</p>
</div>
</div>
</body>
</html>