I have searched the web, youtube, and communities but no solution to this question. I have an app that I am developing using Phonegap Build. I have included the InAppBrowser plugin in my config.xml and works fine with links in the app. The solution or direction I am looking for is a way to include links that are on an external website to open using the InAppBrowser. The links on the external page are dynamic but I am able to add the onClick event. This is what my dynamic link looks like.
<a href="#" onclick="openInAppBrowserBlank(\'' . get_permalink($post->ID) . '\');>Read More</a>
This is one link that I see when I use Firebug to view the html it is generating.
<a onclick="openInAppBrowserBlank('http://website.com/uncategorized/post-one/');" href="#">Read More »</a>
This is the script that I use to load the external page in my app.
<script type="text/javascript">
function expage() {
$("#display").html('<object data="http://website.com" style="position: relative; right:0; top:30px; width:100%; height:100%; overflow:auto; overflow-y:hidden; padding:0px;" />');
}
</script>
This is the DIV that displays the external page.
<div id="display" class="card1" style="position:fixed; top:15px; left:0px; width:100%; height:93%;"></div>
These are scripts attached to my page. Phonegap builds "phonegap.js" into my app.
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/index2.js"></script>
<script type="text/javascript">
app.initialize();
</script>
This is "index2.js"
var ref = null;
function openInAppBrowserBlank(url)
{
try {
ref = window.open(url,'_blank','location=no'); //encode is needed if you want to send a variable with your link if not you can use ref = window.open(url,'_blank','location=no');
ref.addEventListener('loadstop', LoadStop);
ref.addEventListener('exit', Close);
}
catch (err)
{
alert(err);
}
}
function LoadStop(event) {
if(event.url == "http://website.com/x.php"){
// alert("fun load stop runs");
ref.close();
}
}
function Close(event) {
ref.removeEventListener('loadstop', LoadStop);
ref.removeEventListener('exit', Close);
}
Has anyone done something like this or can give me direction?