i want to create INTRO js to my website, when user first time visit my website. I use cookies with PHP. but its not worked.
This is my code
if(isset($_COOKIE["userip"]))
{
echo " $_COOKIE[userip]";
}
else
{
?>
<script>
//I THINK THE PROBLEM IS AT THIS JS LINE
// introJs();
//javascript:introJs.start();
introJs().setOption('showProgress', true).start();
</script>
<?php
setcookie("userip", "mycookiename", time()+3600);
}
<script type="text/javascript" src="intro.js"></script>
but if i put:
introJs().setOption('showProgress', true).start();
in body onload it is work. but what i need is checking cookies first.
pls help me
thank you
my problem is now fixed, i change javascript code like be like this:
<script>
$(document).ready(function(){
javascript:introJs().setOption('showProgress', true).start();
});
</script>
I think your issue is resolved by changing the order of scripts (or maybe adding a close tag to your first):
<!-- load intro.js FIRST -->
<script type="text/javascript" src="intro.js"></script>
<!-- use intro.js -->
<script>
// include any options you want
introJs().start();
// set cookies if you want
// ...
</script>