locked
Why iframe is not loading all webpages in winjs app? RRS feed

  • Question

  • Hi All,

              I took a blank WinJS Store app and placed the below code in default.html file

    <iframe src="http://www.google.com" height="400" width="400"></iframe>

    But the iframe is not loading the google home page. The page is left blank. While if I replace the src value to "http://www.palermo4.com" its working fine. Why is this strange behavior. Do we need to acquire any other permissions kind of thing for some urls? Kindly help me out.

    Thanks in Advance 


    • Edited by raja124 Monday, July 8, 2013 7:31 AM
    Monday, July 8, 2013 7:19 AM

Answers

  • Some sites, like Google, have "frame busting" code on their pages to prevent them from being hosted in an iframe, which is why you see the behavior you do. Other sites, like palermo4.com, do not have such code and thus work fine.

    In Windows 8 there is no workaround for this, unfortunately. In Windows 8.1 Preview you can use the x-ms-webview element instead (See the Webview sample for HTML/JS), which can host sites like Google. This is one of the main scenarios that drove the webview API for 8.1. I also discuss it in the my book's second edition preview (Chapter 4)

    Kraig

    Author, Programming Windows 8 Apps with HTML, CSS, and JavaScript, a free ebook from Microsoft Press


    • Marked as answer by raja124 Tuesday, July 9, 2013 7:26 AM
    Monday, July 8, 2013 4:11 PM