How to open Disclaimer on click with javascript

Posted on 2009-02-23
Last Modified: 2012-05-06
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

Question by:addicktz
    1 Comment
    LVL 75

    Accepted Solution

    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

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now