?
Solved

How to open Disclaimer on click with javascript

Posted on 2009-02-23
1
Medium Priority
?
2,890 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:addicktz
1 Comment
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 23719416
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

755 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