View Full Version : DHTML Modal window v1.1.

05-08-2008, 03:18 AM
I really like this script
DHTML Modal window v1.1.

But i want the window to popup everytime the page loads but if the user click a button or check box that says "don't open anymore" Then it will stop opening for that user.

How can that be done with this scripted ?

05-09-2008, 03:35 PM
Is there anyone that can help me ?

05-10-2008, 03:10 AM
Sure, try the below modified modal.js file. Then, whereas you may have something like:

var agreewin=dhtmlmodal.open("agreebox", "iframe", "modalfiles/agreement.htm", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0", "recal")

You can now add inside agreement.htm a link that when clicked on, closes the modal window plus prevents it from popping up for x days:

<a href="javascript:parent.agreewin.dismiss(2)">Dismiss Window for 2 days</a>

Make sure the variable names in red match up.

05-10-2008, 04:08 AM
That is great how do i turn that in to a check box ?

05-10-2008, 08:20 AM
Well, you could do something like the following:

<input type="check" onClick="if (this.checked) parent.agreewin.dismiss(2)" /> Dismiss Box

That should do it.

05-10-2008, 03:24 PM
uuumm i like it but if i want it to come back i have to wate untill the days are up.

i tryed this

<input type="check" onClick="if (this.checked) parent.agreewin.hide()" /> Dismiss Box

that didn't work i want it to have a check box. And if it stayed checked then never open again. If the user un-checks it re-open the popup.

05-10-2008, 04:33 PM
You would want to use a checkbox and set a cookie pending I agree. Below is a quick example (tested in IE7 and Firefox). Test live version here: http://phpscriptindex.com/dhtmlmodal/demo-modal.htm

<label><input type="checkbox" id="agreeCBox" onclick="if(!this.checked) popAgree();" />I agree to this page's terms of service</label>
<script type="text/javascript">
//w3c setCookie Module -- http://www.w3schools.com/JS/js_cookies.asp
function setCookie(c_name,value,expiredays){
var exdate=new Date();
document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
//w3c getCookie Modue -- http://www.w3schools.com/JS/js_cookies.asp
function getCookie(c_name){
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1){
c_start=c_start + c_name.length+1;
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
return null;

var agreeStatus = getCookie('agree');
var agreeCBox = document.getElementById('agreeCBox');
agreeCBox.checked = true;

function popAgree(){
parent.agreewin=dhtmlmodal.open("agreebox", "iframe", "modalfiles/agreement.htm", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0", "recal");
agreewin.onclose=function(){ //Define custom code to run when window is closed
var theform=this.contentDoc.getElementById("eula") //Access form with id="eula" inside iframe
var yesbox=theform.eulabox[0] //Access the first radio button within form
var nobox=theform.eulabox[1] //Access the second radio button within form
if (yesbox.checked==true){
alert("You agreed to the terms")
}else if(nobox.checked==true){
alert("You didn't agree to the terms")
document.body.innerHTML = 'Access denied';
return true //Allow closing of window in both cases

05-10-2008, 05:12 PM
o your good thast great i will play with the code some more later to night

BIG thank you