1

I need help resolving this Google Chrome Error..."Uncaught Error: SECURITY_ERR: DOM Exception 18"

Here is the code.

//Get Cookie
function get_cookie (cookie_name)
{
    var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
    if (results)
    return ( unescape ( results[2] ) );
    else
    return null;
};

Many thanks, C

Blixt
  • 49,547
  • 13
  • 120
  • 153
  • 1
    Are you calling the page with file:// rather than http:// ?? – CResults Apr 18 '10 at 11:07
  • Yeah, what context? This error is usually associated with cross-window-scripting. Also, `unescape` is a dodgy function which you should only use if you encoded the cookie value with `escape` in the first place. `escape`/`unescape` is not the same as URL-encoding and should usually not be used. – bobince Apr 18 '10 at 11:09
  • @bobince: `unescape` isn't a "dodgy" function. But it's certainly true that he should only use `unescape` if he used `escape` (or something `escape`-compatible) in the first place, and that it's not the same as URI decoding. :-) – T.J. Crowder Apr 18 '10 at 11:28
  • This error only occurs in Chrome for Mac. I have read many posts where other people have been having issues the same. Will keep trying. –  Apr 19 '10 at 15:44

1 Answers1

0

The escape() function was deprecated in JavaScript version 1.5.
Use encodeURI() or encodeURIComponent() instead.