How to open Disclaimer on click with javascript

I need a disclaimer window like the one on 18+ sections (not safe for work)

I have the relevant code from the site, but it is not working, any ideas?
<li><a href="" class="boardlink">Random</a></li>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
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);});
  createCookie('annc',^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: ? {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} : null
var disclaimerHref;
function disclaimerAgree() {
  createCookie('4chan_disclaimer', 1, 365);
  location.href = disclaimerHref;
function disclaimerCancel() {
function disclaimerLinkClick(e) {
  if(e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) return true;
  disclaimerHref = this.href;;
  if(e.preventDefault) e.preventDefault();
  return false;
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 ( 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, which may be located by following the \"<a href=\"/rules\">Rules</a>\" link on the home page.</li></ol>");
dialog.cfg.queueProperty("buttons", [ { text: "I Agree", handler: disclaimerAgree, isDefault: true }, { text: "Cancel", handler: disclaimerCancel } ]);
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);

Open in new window

Who is Participating?
Michel PlungjanConnect With a Mentor IT ExpertCommented:
Error: document.getElementById(opts.parent) is null
Source File:
Line: 8

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

So you miss some wrappers
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.