vendredi 26 juin 2015

Local storage if then statement not recognizing value

I'm using HTML5 local storage to store a value, "clicked" and only display a pop-up if that value is set to "false", clicking ok on the pop-up changes the value to "true" and it then the pop ups are no longer triggered. I've been testing this and the code looks good, no errors but it still shows the popup on every click.

jQuery( document ).ready(function() {

     localStorage.setItem('clicked',"false");
    var clicked = localStorage.getItem('clicked');
              if(clicked = "false") {

  jQuery('.external').click( function(e) {

    var r = confirm("You are now leaving");
    if (r == true) {
     localStorage.setItem('clicked',"true");
        window.open(jQuery(this).prop('href'),"_blank");

    } else {

    }
          e.preventDefault();



});
                       }
else {
      }

Aucun commentaire:

Enregistrer un commentaire