Search code examples
javascriptjquerycsscookiesjquery-cookie

Jquery Cookie usage in Mobile Hybrid app


When I attempt to write a jquery-cookie.js plugin into a mobile-hybrid app that's displaying a web page, I get flicker of the div that is suppose to be displayed, and then it immediately disappear. Without this script the following div will be displayed in a mobile hybrid web page as it should.

<script type="text/javascript">
$(function(){
  if ($.cookie('newappuser')) {
       console.debug($.cookie("newappuser"));
      $('div.instructionalgif').remove();
  }
  else {
      $.cookie('newappuser', 'true', {expires: 7});
      return $('div.instructionalgif').click(function() {
        $('div.instructionalgif').remove();
      });
  }
});
</script>

This will display correctly without the above script.

<div class="instructionalgif" style="display: block;margin:auto;background-image: url('http://cdn.idstatic.com/cms/live/190/Untitled-1.gif?1401950829'); background-repeat: no-repeat; background-position: 50%; background-color: #fff;left:0;right:0;;top:0;bottom:0;opacity:0.8;z-index:999999;position:absolute;"><i class="fa fa-times" style="font-size:3em;padding:10px 0 0 10px;"></i></div>

Anyone know why this might be happening?

Resources: https://github.com/carhartl/jquery-cookie


Solution

  • Apparently jquery .cookie are unable to be used inside of native apps.