JQuery and cookie usage.
-
Hi, I try to insert to “widgets” the following code:
<link rel="stylesheet" type="text/css" href="/wp-content/jquery.fancybox.css"> <style type="text/css"> a {outline: 0 none; text-decoration: none;} a img {border: 0 none;} #wrap { width: 800px; margin: 20px auto; font-family: arial, sans-serif; font-size: 14px;} p.counter span {font-weight: bold;} </style> <script src="/wp-content/jquery.js"></script> <script type="text/javascript" src="/wp-content/jquery.fancybox.js"></script> <script type="text/javascript" src="/wp-content/jquery.cookie-1.3.0.js"></script> <script> $(document).ready(function () { // create cookie var visited = $.cookie('visited'); // visited = 0 if (visited == 1) { $("p.counter").html("Tuoj issoks langas"); // open fancybox after 3 secs on 4th visit setTimeout(function () { $.fancybox.open({ type: 'iframe', href : 'http://labas.lt', }); }, 3000); } else { visited++; // increase counter of visits $("p.counter span").append(visited); // set new cookie value to match visits $.cookie('visited', visited, { expires: 3// expires after one day }); return false; } }); // ready </script>But it does not work for me.
Error: Uncaught TypeError: Cannot read property ‘cookie’ of undefined
var visited = $.cookie('visited'); // visited = 0How can I fix this error?
If you insert a code into a separate file for example. file.php it works. But when you insert it into the wordpress is dont work.
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
The topic ‘JQuery and cookie usage.’ is closed to new replies.