locked
Creating a pop-up EULA - Stuck RRS feed

  • Question

  • I am currently using the following code. 
    <html>
    <body>
    <p>Testing!</p>
    </body>
    <script type="text/javascript" language="javascript">
    
    var agreement = GetCookie();
    
    // checks for cookie and displays disclaimer alert if new user
    
    if (agreement == "") {
    
    var decision = confirm("Test");
    
    if (decision == true) {
    
    // writes a cookie
    
    var oneMinute = 60 * 1000
    
    var oneHour = oneMinute * 60
    
    var oneDay = oneHour * 24
    
    var today = new Date()
    
    var nextXmas = new Date()
    
    nextXmas.setMonth(11)
    
    nextXmas.setDate(31)
    
    var expiredays = nextXmas.getTime() - today.getTime()
    
    expiredays = Math.floor(expiredays/oneDay)
    
    var exdate = new Date()
    
    exdate.setDate(exdate.getDate() + 1)
    
    document.cookie = "PartnerAgreement" + "=" + escape("Agree To Disclaimer") +
    
    ((expiredays == null) ? "" : ";path=/; expires=" + exdate.toGMTString())
    
    }
    
    else {
    
    // redirect
    
    window.location = "/_layouts/signout.aspx";
    
    // or close the browser window
    
    //window.opener='x';
    
    //window.close();
    
    }
    
    }
    
    // gets the Cookie if it exists
    
    function GetCookie() {
    
    if (document.cookie.length > 0) {
    
    c_name = "PartnerAgreement";
    
    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 agreement = unescape(document.cookie.substring(c_start, c_end))
    
    }
    
    }
    
    return "";
    
    }
     document.write(exdate);
    </script>
    </html>
    but the problem I have is that I cannot format the text correctly, so I need help formatting the text or ideally loading a PDF in place of the text.
    • Moved by Bill_Stewart Friday, August 14, 2015 8:01 PM Off-topic
    Wednesday, July 8, 2015 6:45 PM

Answers

  • You can't from an HTML page.  You can from an HTA but it must reside locally.

    If this is from a web server then post in http://forums.iis.net to learn how to do it.


    \_(ツ)_/

    Wednesday, July 8, 2015 8:38 PM

All replies

  • No idea what you mean by formatting.  In HTML we use CSS to format the HTML.

    For web page help you will need to post in web developers forum.


    \_(ツ)_/

    Wednesday, July 8, 2015 7:45 PM
  • Here is what you code look s like.  It makes little sense along with your request.  You will have to ask a more specific question no matter where you post.

    <html>
    <body>
    <p>Testing!</p>
    </body>
    <script type="text/javascript" language="javascript">
    
    	var agreement = GetCookie();
    
    	// checks for cookie and displays disclaimer alert if new user
    	if (agreement == "") {
    		var decision = confirm("Test");
    		if (decision == true) {
    			// writes a cookie
    			var oneMinute = 60 * 1000
    			var oneHour = oneMinute * 60
    			var oneDay = oneHour * 24
    			var today = new Date()
    			var nextXmas = new Date()
    			nextXmas.setMonth(11)
    			nextXmas.setDate(31)
    			var expiredays = nextXmas.getTime() - today.getTime()
    			expiredays = Math.floor(expiredays/oneDay)
    			var exdate = new Date()
    			exdate.setDate(exdate.getDate() + 1)
    			document.cookie = "PartnerAgreement" + "=" + escape("Agree To Disclaimer") + ((expiredays == null) ? "" : ";path=/; expires=" + exdate.toGMTString())
    		}else{
    			// redirect
    			window.location = "/_layouts/signout.aspx";
    			// or close the browser window
    			//window.opener='x';
    			//window.close();
    		
    		}
    	}
    
    	// gets the Cookie if it exists
    	function GetCookie() {
    		if (document.cookie.length > 0) {
    			c_name = "PartnerAgreement";
    			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 agreement = unescape(document.cookie.substring(c_start, c_end))
    			}
    		}
    		return "";
    	}
    	document.write(exdate);
    	
    </script>


    \_(ツ)_/


    • Edited by jrv Wednesday, July 8, 2015 7:52 PM
    Wednesday, July 8, 2015 7:52 PM
  • Well see variable "Confirm" is actually a dialog that appears, so if you run that as html you should get a pop-up that says "Test" and then you can select ok/cancel. What I would like to do is in place of the "Test" text I would like to display or use a word document or PDF document.

    Mainly because the confirm dialog isn't big enough.
    • Edited by Chuck_1987 Wednesday, July 8, 2015 8:15 PM A word.
    Wednesday, July 8, 2015 8:14 PM
  • You can't from an HTML page.  You can from an HTA but it must reside locally.

    If this is from a web server then post in http://forums.iis.net to learn how to do it.


    \_(ツ)_/

    Wednesday, July 8, 2015 8:38 PM
  • Yeah, I need something in HTML/JavaScript. Ideally the user would go to a site, like google.com, and they would get a pop-up that would show them an EULA which they could either agree or cancel and if they agree they go to google.com if they do not agree they get redirected to another page. And it would store a cookie for a day prior to expiring and required another eula acceptance.

    My issue is that I have it working in Jscript BUT i cannot change the width of the jscript confirm window.

     
    Thursday, July 9, 2015 4:08 AM
  • This is not a web development forum.  You need to post in the forum I linked above or another web forum.  All of what you want can be easily done from a web page-.  You just need to post in the correct forum.

    \_(ツ)_/

    Thursday, July 9, 2015 4:15 AM