Sia
Sia

Reputation: 63

How to open a local HTML page by windows.open() in ionic2?

I need to open one of my local HTML page by window.open() in ionic2 specifically for my iOS version.

I have a HTML page for example in src > app > assets > test > test.html (I know this is not a right place) I have been trying to open this pages with window.open(url,target) but could not find any solution. I have tried many combinations.

this was the first one:

window.open('assets/test/test.html', '_system');

I also have added corodva plugin "cordova plugin install cordova-plugin-file" and followed some examples like what explained here: https://medium.com/@barsh/cordova-navigating-to-local-content-from-a-website-3ed774c58d37

I have tried this combinations :

 window.open('cdvfile://localhost/bundle/www/assets/test/test.html', 
'_system');
window.open('cdvfile://localhost/persistent/www/assets/test/test.html', 
'_system');

and many other combinations but no success. I have problem to understand how to make the path (relative or absolute).

NOTE: As I see friends suggested in-app Browser, I explain more about the issue. Since the HTML page contains A-frame(Augmented Reality with the help of Ar.js) and we have no solution to load this page in ionic app for iOS version (for more information over the problem you could see my previous question: Is there any way to make the background of a 3D-model transparent in a-scene in ionic?) I am thinking of another solution. The solution would be opening this HTML page in Safari explicitly. In this case in-app Browser did not help me, but window.open seems to work for opening AR related pages. Now, what I want to test is if I can make my local html page (containing AR) open in Safari by window.open(). I hope this part makes the question more clear.

Upvotes: 1

Views: 1270

Answers (2)

jogaleumesh
jogaleumesh

Reputation: 156

use the In-App Browser plugin this will open your HTML page in your app. go through the link - https://ionicframework.com/docs/v3/native/in-app-browser

Upvotes: 0

Abhishek Rlogical
Abhishek Rlogical

Reputation: 64

The best solution for openeing a link within the app is "In App Browser"

In App Browser

Using this feature links can be opened within the App.

Upvotes: 0

Related Questions