Android : Inappbrowser closing with javascript on client side

on Wednesday, January 28, 2015


I am trying to display a webpages using in-app-browser in android platform of phone gap. window.open() opening a url webpage which can call another html pages on to the server. I am trying to close the in-app-browser on any page (i.e., on very first loaded page or on intermediate page loaded or on the last page) by clicking a close hyperlink which calls a javascript function iabClose(event) but the in-app-browser is not closing.


Please help me if anybody knows the solution or any other better way of closing in-app-browser. Thanks in advance


Code:



<html>
<head>
<script type="text/javascript" charset="utf-8">
var iabRef = null;

function inApp() {
iabRef = window.open('http://202.65.155.246/Real_Time_Data /SSEClient.aspx', '_blank', 'location=no');
iabRef.addEventListener('loadstop', iabLoadStop);
iabRef.addEventListener('exit', iabClose);
}

function iabLoadStop(event) {
if(event.url == "http://202.65.155.246/Real_Time_Data/CloseIAB.aspx"){
iabRef.close();
}
}

function iabClose(event) {
iabRef.removeEventListener('loadstop', iabLoadStop);
iabRef.removeEventListener('exit', iabClose);
}
</script>
<title>Hello World</title>
</head>
<body>
<a href="http://202.65.155.246/Real_Time_Data/SSEClient.aspx" onclick="inApp()" style="font-size:30px;">Click Here</a> </br></br>
<a href="" onclick="iabExit()" style="font-size:30px;">Exit</a>
</body>
</html>

0 comments:

Post a Comment