opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

Chrome Error: SecurityError: DOM Exception 18 Error: An attempt was made to break through the security policy of the user agent. #205

Closed alejandrocao closed 11 years ago

alejandrocao commented 11 years ago

I get the following error when trying to run your sample locally.

http://jsfiddle.net/ocdemo/CE86s/

Error: SecurityError: DOM Exception 18
Error: An attempt was made to break through the security policy of the user agent.
    at Browser.self.url (http://code.angularjs.org/1.0.7/angular.js:3147:30)
    at Browser.$browser.url (https://rawgithub.com/opitzconsulting/jquery-mobile-angular-adapter/master/compiled/jquery-mobile-angular-adapter.js:1354:32)
    at Browser.$browser.url (https://rawgithub.com/opitzconsulting/jquery-mobile-angular-adapter/master/compiled/jquery-mobile-angular-adapter.js:1422:36)
    at http://code.angularjs.org/1.0.7/angular.js:5636:22
    at Object.Scope.$eval (http://code.angularjs.org/1.0.7/angular.js:8057:28)
    at Object.Scope.$digest (http://code.angularjs.org/1.0.7/angular.js:7922:25)
    at Object.$rootScope.$digest (https://rawgithub.com/opitzconsulting/jquery-mobile-angular-adapter/master/compiled/jquery-mobile-angular-adapter.js:322:31)
    at Object.$rootScope.$digest (https://rawgithub.com/opitzconsulting/jquery-mobile-angular-adapter/master/compiled/jquery-mobile-angular-adapter.js:369:31)
    at Object.Scope.$apply (http://code.angularjs.org/1.0.7/angular.js:8143:24)
    at Object.$rootScope.$apply (https://rawgithub.com/opitzconsulting/jquery-mobile-angular-adapter/master/compiled/jquery-mobile-angular-adapter.js:362:27) 
tbosch commented 11 years ago

Hi, are you running this from the file system? If so, please try again with a local web server running...

Tobias

alejandrocao commented 11 years ago

Hi Tobias,

Yes, I'm running my samples from file system. It is not possible to do that?

I add this to my controller and now I can run the sample.

mod.config(function($locationProvider) {
    $locationProvider.html5Mode(false);
});

However I also have to change my links from:

<li><a ng-href="page2/1">Option 1</a></li>

to:

<li><a ng-href="index.html#!/page2/1">Option 1</a></li>

Is it a better way to do that?

Thanks, Alejandro

tbosch commented 11 years ago

Hi, no, this is the only way if you run this from a file system, as otherwise angular uses the html5 history api, which resulted in the error you saw.

Tobias

tbosch commented 11 years ago

Closing this, as running from file system is not supported.