Results 1 to 8 of 8

Thread: DHTML Modal window v1.1.

  1. #1
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DHTML Modal window v1.1.

    I really like this script
    http://www.dynamicdrive.com/dynamici...dhtmlmodal.htm
    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 ?

  2. #2
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Is there anyone that can help me ?

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Sure, try the below modified modal.js file. Then, whereas you may have something like:

    Code:
    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:

    Code:
    <a href="javascript:parent.agreewin.dismiss(2)">Dismiss Window for 2 days</a>
    Make sure the variable names in red match up.

  4. #4
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That is great how do i turn that in to a check box ?

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Well, you could do something like the following:

    Code:
    <form>
    <input type="check" onClick="if (this.checked) parent.agreewin.dismiss(2)" /> Dismiss Box
    </form>
    That should do it.

  6. #6
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    uuumm i like it but if i want it to come back i have to wate untill the days are up.

    i tryed this

    Code:
    <form>
    <input type="check" onClick="if (this.checked) parent.agreewin.hide()" /> Dismiss Box
    </form>
    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.

  7. #7
    Join Date
    May 2007
    Location
    By the beach
    Posts
    23
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    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

    HTML Code:
    <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();
     	exdate.setDate(exdate.getDate()+expiredays);
    	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){
    	if(document.cookie.length>0){
    		c_start=document.cookie.indexOf(c_name + "=");
    		if (c_start!=-1){ 
    			c_start=c_start + c_name.length+1; 
    			c_end=document.cookie.indexOf(";",c_start);
    			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');
    if(agreeStatus=='1'){
    	agreeCBox.checked = true;
    }else{	
    	popAgree();
    }
    
    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")
    			setCookie('agree','1',1);
    			agreeCBox.checked=true;		
    		}else if(nobox.checked==true){
    			alert("You didn't agree to the terms")
    			setCookie('agree','1',-1);		
    			document.body.innerHTML = 'Access denied';			
    		}
    		return true //Allow closing of window in both cases
    	}
    }
    </script>

  8. #8
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    o your good thast great i will play with the code some more later to night

    BIG thank you

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •