How to open Disclaimer on click with javascript

I need a disclaimer window like the one on

http://www.4chan.org 18+ sections (not safe for work)

I have the relevant code from the site, but it is not working, any ideas?
<li><a href="http://img.4chan.org/b/imgboard.html" class="boardlink">Random</a></li>
 
<script type="text/javascript" src="http://yui.yahooapis.com/2.4.1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.4.1/build/connection/connection-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.4.1/build/animation/animation-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.4.1/build/container/container-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.4.1/build/menu/menu-min.js"></script>
<script type="text/javascript" src="http://content.4chan.org/js/fp.1.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
function announceCloseClick() {
  document.getElementById("announce").style.overflow = 'hidden';
  var anim = new YAHOO.util.Anim('announce', { height: { to: 0 }, padding: { to : 0 } }, 0.25);
  anim.onComplete.subscribe(function(){var el=this.getEl();el.parentNode.removeChild(el);});
  anim.animate();
  createCookie('annc', this.name.replace(/^annc/,""), 365);
  return false;
}
 
YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName("closebutton","a","announce"), "click", announceCloseClick);
 
var dialog = new YAHOO.widget.SimpleDialog("disclaimer-dialog", {
  width: "300px",
  fixedcenter: true,
  modal: true,
  visible: false,
  draggable: false,
  iframe: false,
  effect: YAHOO.env.ua.gecko ? {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} : null
});
 
var disclaimerHref;
function disclaimerAgree() {
  createCookie('4chan_disclaimer', 1, 365);
  location.href = disclaimerHref;
}
function disclaimerCancel() {
  dialog.hide();
}
function disclaimerLinkClick(e) {
  if(e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) return true;
  disclaimerHref = this.href;
  dialog.show();
  if(e.preventDefault) e.preventDefault();
  return false;
}
 
dialog.setHeader("<h2>Disclaimer</h2>");
dialog.setBody("<p>By entering this section of the website, in exchange for use of this website, you the user hereby agree to the following:<ol><li>The content of this website is for mature viewers only and may not be suitable for minors. If you are a minor or it is illegal for you to view nudity or mature images and language, do not proceed.</li><li>This site is presented to you AS IS, with no warranty, express or implied. By clicking \"I Agree\" and then viewing our site, you agree not to hold the webmaster and staff of this site (4chan.org) liable for any damages from your use of these boards.</li><li>As a condition of using this site, you must fully understand, and comply with the rules of 4chan.org, which may be located by following the \"<a href=\"/rules\">Rules</a>\" link on the home page.</li></ol>");
dialog.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_WARN); 
dialog.cfg.queueProperty("buttons", [ { text: "I Agree", handler: disclaimerAgree, isDefault: true }, { text: "Cancel", handler: disclaimerCancel } ]);
dialog.render(document.body);
YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName("boardlink","a"), "click", disclaimerLinkClick);
filterButtonMenu.getItem(0, 0).cfg.setProperty("checked", true);
filterButtonMenu.getItem(1, 1).cfg.setProperty("checked", true);
optionButtonMenu.getItem(0).cfg.setProperty("checked", true);
/*]]>*/
</script>

Open in new window

LVL 1
addicktzAsked:
Who is Participating?
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
Error: document.getElementById(opts.parent) is null
Source File: http://content.4chan.org/js/fp.1.js
Line: 8

Error: optionButtonMenu is undefined
Source File: file:///c:/temp/test.html
Line: 60

So you miss some wrappers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.