Firefox SecurityError: “The operation is insecure.”

匿名 (未验证) 提交于 2019-12-03 02:30:02

问题:

I am using Backbone.LocalStorage plugin with backbone app. It is working fine in chrome and safari however, it is giving me below error in firefox.

DOMException [SecurityError: "The operation is insecure." code: 18 nsresult: 0x80530012 location: http://localhost:8000/js/libs/backbone.localStorage/backbone.localStorage.js?version=1453910702146:137]

I am using python simpleHttpServer

How can I resolve this error?

UPDATE

Here is my code.

paths: {     'jquery'        : 'libs/jquery/dist/jquery',     'underscore'    : 'libs/underscore/underscore',     'backbone'      : 'libs/backbone/backbone',     'localStorage'  : 'libs/backbone.localStorage/backbone.localStorage',     'text'          : 'plugins/text' } 

Here is collection where localStorage is used.

var Items = Backbone.Collection.extend({      model: SomeModel,      localStorage: new Backbone.LocalStorage('items'), }); 

UPDATE 2

I am using firefox 36.

UPDATE 3

It seems like it is a CORS issue but my firefox version is 36. Which should be fine.

UPDATE 4

I am also getting this error in firefox nightly version 44. I also updated my firefox to version 44. Still same error.

回答1:

Make sure Firefox has coockies enabled. The setting can be found under Menu/Options/Privacy/History

In dropdown there select either Remember History or if You prefer Use custom settings for history, but select option Accept cookies from sites

hope it helps.



回答2:

This happens when we tries to access a resources (CSS...) that are located on different domains to deal with this error we can use :

                   try {                      //your critical access to ressources !                      //rules = document.styleSheets[i].cssRules;                         } catch(e) {                    if(e.name !== "SecurityError") {                        throw e;                        } 


回答3:

Make sure your domains are same. verify Same Origin Policy which means same domain, subdomain, protocol (http vs https) and same port.

What is Same Origin Policy?
How does pushState protect against potential content forgeries?



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!