2

I am using $.cookie('mycookie').split('|')[1] it is working in FF but in IE8 i it is throwing "Object doesn't support this property or method".. Any suggestion?

Here is what i am trying to do,

if($.cookie('mycookie') != null && $.cookie('mycookie').split('|')[1] != '')
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
ACP
  • 34,682
  • 100
  • 231
  • 371
  • this question might help you http://stackoverflow.com/questions/2608575/jquery-split-and-indexof-results-in-object-doesnt-support-this-property-or-me/2608618#2608618 – Rafay Aug 19 '11 at 05:45
  • What does `alert($ instanceof jQuery);` give you? – karim79 Aug 19 '11 at 05:45
  • @Karim79 I tried `alert($.cookie('mycookie'))` it gives `null||||false||0` – ACP Aug 19 '11 at 05:52
  • This might be to do with strange IE8 split behaviour - try using the cross browser split code found here: http://blog.stevenlevithan.com/archives/cross-browser-split – Timothy Jones Aug 19 '11 at 06:57

1 Answers1

1

A quick look at the plugin indicates that is the expected value if the cookie doesn't exist. The default state is null and then a string if a value is found. Why not just look at document.cookie first yourself:

alert(decodeURIComponent(document.cookie.replace(";","\n\n")));

If the cookie value you are looking for does in fact exist, then I would verify the plugin actually loaded properly:

alert($.cookie.toString());

The get portion of that plugin is about 15 lines so would be trivial to debug if it is the problem. The returned value right now is null, which has no split() method and therefore you are seeing the error in IE as expected.

Jeff
  • 846
  • 8
  • 13