Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Cookie Redirect
    primarykey
    data
    text
    <p>When people type in my URL, I want them to click North Carolina or Virginia. After they click, it redirects them to either www.myurl.com/nc or www.myurl.com/va. After they answer that question, next time they visit my site, it will redirect them to the appropriate page without clicking NC or VA again. Here's what I've got so far. I feel like I'm close, but I honestly have no clue what I'm doing.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;a href="#" onClick="window.location = "http://www.myurl.com/nc"" value="nc"&gt;North Carolina&lt;/a&gt; &lt;br /&gt; &lt;br /&gt; &lt;a href="#" onClick="window.location = "http://www.myurl.com/va"" value="va"&gt;Virginia&lt;/a&gt; &lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function setCookie { document.body.style.state = size; createCookie('state', size, 90); } var state = readCookie('state'); if (state !== null) { // cookie exists setCookie(state); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I also have separate script file with the following code:</p> <pre><code>// JavaScript Document function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i &lt; ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload