almost 9 years ago
In this post, you will see the events that can be used in InAppBrowser plugin.
There are different methods:
InAppBrowser.addEventListener:
It will add a listener for an event from InAppBrowser.
here ref is reference to InAppBrowser window. eventname can be of these types:
Example:
var ref = cordova.InAppBrowser.open('http://google.com', '_blank', 'location=yes');
ref.addEventListener('loadstart', function(event)
{
alert(event.url);
});
var ref = cordova.InAppBrowser.open('http://google.com', '_blank', 'location=yes');
ref.addEventListener('loadstart', function(event)
{
alert(event.url);
});
InAppBrowser.removeEventListener:
It will remove a listener for an event in InAppBrowser.
The properties are same as addEventListener.
Example:
var ref = cordova.InAppBrowser.open('http://google.com', '_blank', 'location=yes');
var CallbackFunc = function(event) { alert(event.url); }
ref.addEventListener('loadstart', CallbackFunc);
ref.removeEventListener('loadstart', CallbackFunc);
var ref = cordova.InAppBrowser.open('http://google.com', '_blank', 'location=yes');
var CallbackFunc = function(event) { alert(event.url); }
ref.addEventListener('loadstart', CallbackFunc);
ref.removeEventListener('loadstart', CallbackFunc);
InAppBrowser.close:
It will close the InAppBrowser window.
Example:
InAppBrowser.show:
It will display InAppBrowser window, if it is hidden.
InAppBrowser.executeScript:
It can be used to inject javascript code into the window of inappbrowser.
Example:
var ref = cordova.InAppBrowser.open('http://google.com', '_blank', 'location=yes');
ref.addEventListener('loadstop', function() {
ref.executeScript({file: "script.js"});
});
var ref = cordova.InAppBrowser.open('http://google.com', '_blank', 'location=yes');
ref.addEventListener('loadstop', function() {
ref.executeScript({file: "script.js"});
});
InAppBrowser.insertCSS:
It can be used to inject css file into InAppBrowser window.
Example:
var ref = cordova.InAppBrowser.open('http://google.com', '_blank', 'location=yes');
ref.addEventListener('loadstop', function() {
ref.insertCSS({file: "style.css"});
});
var ref = cordova.InAppBrowser.open('http://google.com', '_blank', 'location=yes');
ref.addEventListener('loadstop', function() {
ref.insertCSS({file: "style.css"});
});
Hope this will help you to use InAppBrowser events. :)
0 Comment(s)