I have a hybrid application developed using Apache Cordova, within that application I am using " inappbrowser ". Now the requirement is to open Camera or Gallery from the inappbrowser, I am not able to figure out how to achieve this.
For developing this application I am using backbone.js, JQuery, bootstrap.js.
Here is the code snippet of Backbone's View :
var mainScreenView = Backbone.View.extend({
el: $('.panel'),
templateMainScreen: _.template($('#templateOne').html()),
events: {
"click #inputBtnSubmit": "openWebView",
"click #clickSettings": "openSettings"
},
initialize: function(){
this.render();
},
render: function () {
alert($(this.el).find('.panel-body'));
var bindElement = $(this.el).find('.panel-body');
bindElement.html(this.templateMainScreen());
return this;
},
openWebView: function () {
var textValue = $('#inputValue').val();
cordova.InAppBrowser.open('**Link to an external webpage which asks for Camera or Gallery control** ', '_blank', 'location=no');
// After inappbrowser is called to load a external webpage (On a button click Camera Intent or Gallery should open)
}
});
var appView = new mainScreenView;
Thanks in advance.
Instead of using inappBrowser, i ended up in implementing HTML iframe. That is, What things I wanted inappBrowser to do, now I am able to do using iframe. You can have access to Camera or Gallery or File Explorer, similar to that of a Native Phone's Browser.
Here is what I have done to solve the above problem:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<title>Hello World!</title>
<style type='text/css'>
body, html, iframe {
margin: 0;
padding: 0;
border: 0px none;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<script type="text/javascript" src="cordova.js"></script>
<iframe src="http://SomeWebPage" width="97%" height="97%"></iframe>
</body>
Hope this helps others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With