Unsafe JavaScript attempt to access frame in Googl

2019-03-05 02:17发布

Our web application (based on HTML5, SVG & JS) runs fine in all the browsers except Google Chrome.

In Google Chrome, the normal javascript events run fine, however, all the javascript events attached to the iFrame are not executed. We get the error in the console:

Unsafe JavaScript attempt to access frame

At the moment, the application is locally hosted and this problem cropped up during inhouse testing.

Googling this brings up lots of posts but none suggests any concrete solution. Any suggestions?

2条回答
迷人小祖宗
2楼-- · 2019-03-05 02:58

Please make sure that both the iframe and main page are using the same protocol (i.e. both https or both http, but not mixed) and are on the same domain (i.e. both www.example.com and not example.com and dev.example.com). Also there's the possibility that something tries to use the file:// protocol, which will also cause this message.

查看更多
看我几分像从前
3楼-- · 2019-03-05 03:08

As an additional security measure, Chrome treats every "file" path as its own origin rather than treating the entire "file" scheme as a single origin (which is what other browsers do). This behavior applies only to "file" URLs and you can force Chrome to revert to a single local origin (like other browsers) by passing the --allow-file-access-from-files switch at startup.

You can find more information on the risks associated with local origins described here: http://blog.chromium.org/2008/12/security-in-depth-local-web-pages.html

查看更多
登录 后发表回答