After wondering a lot to have ionic WebView, I come to get this task done by using these steps-
- install inappbrowser in the application by using this path, and follow the steps to get install.
- make sure you have all html, images and css in assets directories
- for eg-
- www/assets/html.
- www/assets/css.
- www/assets/images etc..
- open file where your want to access the view from assets and type
<a class=”item” href=”#” onclick=”window.open(‘http://www.nraboy.com/contact’, ‘_self’, ‘location=yes’); return false;”>
External Link Profile
</a>
<a class=”item” href=”#” onclick=”window.open(‘http://localhost:8100/ionic-lab’, ‘_self’, ‘location=yes’); return false;”>
Local Link of app
</a>
<a class=”item” href=”#” onclick=”window.open(‘/assets/challenge/my-page.html’,’_self’);”>
Open page
</a>
- make sure that link format must be in bellow format as-
var ref = cordova.InAppBrowser.open(url, target, options);
- where –
-
- ref: Reference to the
InAppBrowser
window when the target is set to'_blank'
. (InAppBrowser) - url: The URL to load (String). Call
encodeURI()
on this if the URL contains Unicode characters. - target: The target in which to load the URL, an optional parameter that defaults to
_self
. (String)_self
: Opens in the Cordova WebView if the URL is in the white list, otherwise it opens in theInAppBrowser
._blank
: Opens in theInAppBrowser
._system
: Opens in the system’s web browser.
- options: Options for the
InAppBrowser
. Optional, defaulting to:location=yes
. (String)
- ref: Reference to the
- read the document carefully which will help you to get the task done.
Have a nice day!!!