1

Does anyone know of a good solution to suppress the warning messages that are shown in the Chrome dev tool console "Unsafe JavaScript attempt to access frame with URL" that happens when trying to access frames from a different domain?

Right now, I have a function that checks if the window is accessible. Every time this function is executed on a window object from a different domain, a warning message will get displayed in the Chrome Dev tools console. This happens quite frequently and the console becomes polluted with all these warnings, making hard to spot real JS errors.

I was thinking maybe there's a way to suppress these warnings in the console? Or better, is there a better way to write code to check if a window is accessible or not?

Here's what I do:

function isWindowAccessible(win) {
    var accessible = null;
    try {
        accessible = win.location.href;
    } catch (e) {}
    return (typeof accessible === 'string');
}
David Ly-Gagnon
  • 411
  • 4
  • 15
  • possible duplicate of [Unsafe JavaScript attempt to access frame with URL](http://stackoverflow.com/questions/4324108/unsafe-javascript-attempt-to-access-frame-with-url) – rlemon Feb 28 '13 at 21:55
  • 1
    a google search returned a full page of similar questions to this one: I skimmed a few and picked this. – rlemon Feb 28 '13 at 21:55
  • That's not a solution to my problem. This post only says that you can change the location url... I'm trying to suppress "unsafe attemps" warning in the console here. – David Ly-Gagnon Feb 28 '13 at 22:24
  • the only way to suppress those warnings is to make it so they don't exist. – rlemon Feb 28 '13 at 22:45
  • Agree, but given a function as shown above, how would you do that ? That is, given a window object as input, how would you test whether the window is accessible without generating the errors "unsafe JavaScript attempt to access frame" ? – David Ly-Gagnon Mar 02 '13 at 05:57
  • know what you are loading in your iframes. – rlemon Mar 02 '13 at 14:56

1 Answers1

0

You can run Chrome with security disabled (command line flag is --disable-web-security). I've done this to bypass some cross-domain issues for automated browser testing within iframes. It will let you do a ton of the sort of insecure stuff that browsers usually consider illegal, without complaining a bit.

jm0
  • 3,294
  • 2
  • 16
  • 18