I am working on an ionic framework based mobile application. My project is a side menu based application. On clicking the item in the side menu, I need to load an external website inside ion-content and hide side menu of the loaded website but I can’t figure it out how to do it.
I tried ngCordova InAppBrowser, but it loads website in a separate full screen.
I also tried iFrame, but I couldn’t load the website inside ion-content. Getting following msg “refused to display url in a frame because it set ‘x-frame-options’ to ‘sameorigin’”. To avoid clickjacking, the x-frame-options in website is set to sameorigin.
I also tried iFrame, but I couldn’t load the website inside ion-content. Getting following msg “refused to display url in a frame because it set ‘x-frame-options’ to ‘sameorigin’”. To avoid clickjacking, the x-frame-options in website is set to sameorigin.
Angular is the underlying framework that powers Ionic.
Angular has a mechanism to prevent cross-site scripting attacks (XSS).
For example, when binding a URL in an <a [href]="someValue"> hyperlink, someValue will be sanitized so that an attacker cannot inject e.g. a javascript: URL that would execute code on the website.
Please refer to here.
This might be the solution. But after using it another problem occur. When I press the back button sometimes the url doesnot change and it all the other page in the html.
Since I stumbled over this post a couple of times, let me quickly provide an answer for Googlers who come here:
Angular doesn’t allow to load external pages by default, due to possible security risks.
To get this done, you need to tell the application that the URL is safe,
In your page.ts, inject the DomSanitizer and then tell the app that the URL is safe:
That’s the way I add content to my apps that needs to be changed from outside (e.g. Help, TnC)
However, this comes with some challenges if you provide navigation items / links inside this HTML pages, as the user might get los easily as he doesn’t know what the app is and the external HTML page
I try to avoid loading complex sites with secondary navigations.