Search code examples
javascripthtmliframewindows-8winjs

WinJS - Ignore iframe javascript errors


I'm building a WinJS app which is using iframes to display web pages.

When testing and running the application I am bombarded with "Access Denied" errors.

I'm not trying to interact with the iframe contents. I'm just trying to display the web page.


This is how I'm displaying external web pages within the app.

<iframe src="http://imgur.com/Yk299"></iframe>

This is an example of the errors thrown.

Exception was thrown at line 17, column 363 in       
http://partner.googleadservices.com/gampad/google_ads_gpt.js

0x80070005 - JavaScript runtime error: Access is denied.

I have no idea how to deal with this.

If these errors can be ignored is there any way to set Visual Studio to ignore them?

Help would be great.


Solution

  • A couple of options, depending on your comfort level with what the scripts are doing and their criticality to your app. It looks like quite a few exceptions for the link you provided are from Google ad services; there are others that are Permission Denied from a different source.

    You can control which exceptions will trigger a break in the debugger by opening Exception Settings when you hit the first exception (as shown below) or go to the Debug>Exceptions... option (Ctrl+Alt+E) in the Visual Studio menu.

    enter image description here

    You could also set the sandbox attribute on the iframe. For instance, setting the following eliminated all of the exceptions:

    <iframe src="http://imgur.com/Yk299" sandbox="allow-top-navigation"></iframe>
    

    Of course, this has potentially significant implications on app security, so do this only for sites with content that you have vetted and trust.