You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by Apache Wiki <wi...@apache.org> on 2012/12/10 23:04:50 UTC

[Cordova Wiki] Update of "InAppBrowser" by ShazronAbdullah

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cordova Wiki" for change notification.

The "InAppBrowser" page has been changed by ShazronAbdullah:
http://wiki.apache.org/cordova/InAppBrowser?action=diff&rev1=8&rev2=9

Comment:
Added docs for events, close() function

  
  == Specification ==
  
- '''window.open( strUrl, strWindowName[, strWindowFeatures])'''
+ '''var ref = window.open( strUrl, strWindowName[, strWindowFeatures])'''
  
  ```strUrl```
     this is a url, prefixed with a scheme for external urls or a filename for urls that exist in the local www folder
@@ -35, +35 @@

  	
  	location --> set to 'yes' or 'no' to turn the location bar on or off for the InAppBrowser
  	
+ window.open returns an object that you can listen for three events on: "loadstart", "loadstop" and "close", as well as call the "close()" function.
+ 
  
  == Example usage ==
  
@@ -71, +73 @@

  window.open('http://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
  }}}
  
- window.location = 'foo'  is equivalent to the '_self' options above.
+ 
+ === 4. Events ===
+ 
+ {{{#!highlight javascript
+ var ref = window.open('http://whitelisted-url.com', '_blank');
+ ref.addEventListener('loadstart', function(event) { alert(event.type + ' - ' + event.url); } );
+ ref.addEventListener('loadstop', function(event) { alert(event.type + ' - ' + event.url); } );
+ ref.addEventListener('exit', function(event) { alert(event.type); } );
+ }}}
+ 
+ The "event" object has two properties: "type" and "url".
+ 
+     ```type```
+         corresponds to the event name
+ 
+     ```url```
+         the relevant url for the event
+ 
+ === 5. Close the InAppBrowser ===
+ 
+ {{{#!highlight javascript
+ var ref = window.open('http://whitelisted-url.com', '_blank');
+ ref.close();
+ }}}
+ 
  
  {{{#!wiki tip
  '''Tip'''
  
- Local and whitelisted URLs should be opened with Cordova functionality by default (_self) and you have to be explicit if you want those trusted resources opened without Cordova functionality (_blank or _system).
+ Local and whitelisted URLs should be opened with Cordova functionality by default (_self) and you have to be explicit if you want those trusted resources opened without Cordova functionality (_blank or _system). Also -- window.location = 'foo'  is equivalent to the '_self' options above.
  }}}
  
  == Testing InAppBrowser ==