“Unsafe JavaScript attempt to access frame with URL…” error being continuously generated in Chrome webkit inspector

前端 未结 5 2330
孤街浪徒
孤街浪徒 2020-12-02 08:56

Chrome (or any other webkit browser) throws a ton of these \"Unsafe JavaScript attempt to access frame with URL...\" when working with the Facebook API for example.

5条回答
  •  难免孤独
    2020-12-02 09:21

    Whats the problem?

    Tons of Unsafe JavaScript attempt to access frame with URL... error messages in the Chrome JS console.

    As @thechrisproject points out, these errors are caused by many reputable 3rd party api's and widgets, including but not limited to:

    • The Facebook JS SDK
    • Vimeo Iframe Embed
    • Google Maps Iframe Embed

    My understanding on the why: (please correct me if I'm wrong)

    Chrome has stricter security settings and/or shows more such errors than competing browsers. API/widget/embed authors attempt to do things (cross-domain/frame) that will not work in all browsers (probably for their own reporting/analytics) but that don't actually effect the usuabilty of their widget if it doesn't work (just causes a lot of annoying errors)

    Quick Answer

    NO, you cannot (just) suppress these errors in the chrome console.

    Solutions?

    • Deal with it. These errors do not actually break these 3rd party apis and widgets, they just make the console much more difficult to use
    • you can set the console to log only Warnings, Logs, or Debug messages. This will hide ALL errors.
    • you can use another browser
    • As @Dagg_Nabbit. pointed out, you can allow cross-domain requests by running chrome with the --disable-web-security command line option. More information here: Disable same origin policy in Chrome. Note that this setting will negatively effect the security of your browser. I have 2 chrome shortcuts so I can open it with or without this flag.

提交回复
热议问题