The 'if' statement is pretty fundamental to JavaScript. It doesn't fail. So if something is going wrong, then likely either the value of 'cookie' is not quite what you expect, or the code inside the if isn't working.
Could the cookie value have some whitespace in it? You wouldn't see that in an alert. You can check it with things like this:
alert( cookie.length );
alert( '{' + cookie + '}' );
-Mike
On Thu, Dec 3, 2009 at 4:46 AM, shapper <mdmoura@gmail.com> wrote:
Hello,
I have the following code:
alert($.cookies.get("WCA.Player"));
var cookie = $.cookies.get("WCA.Player");
if (cookie == null || cookie == 'Play') {
$("#JPlayer").play();
}
The alert gives me the correct value which is null or 'Play' but the
if is not working correctly.
Am I doing something wrong?
Thanks,
Miguel
No comments:
Post a Comment