14 May 2010

IE + navigator.cookieEnabled => security warning

Has anybody seen messages from IE with following text after adding peace of JavaScript to the page?
"This page has an unspecified potential security risk. Would you like to continue?"
- Yes/No
I was very surprised when received this message. There is no special exceptions of "Permission denied" kind and also you can't handle it via using window.onerror event. The source of this warning was in the usage of navigator.cookieEnabled property. I just needed to know whether cookies are enabled.
I fixed it by using small workaround: create cookie and try to read it. In case of disabled cookies you will no be able to read it.
function cookiesEnabled() {
var name = "__test_cookie__";
document.cookie = name;
return (document.cookie.indexOf(name) != -1);
}
Honestly saying that was not default IE browser. IE was used as a component in another software to render web-pages. I assume it's running in some specific security/privacy mode.

No comments:

Post a Comment

Profile