I have also tried a jQuery solution with has the same effect.
- 132 Posts
- 3 Reply Likes
- confused
Posted 5 years ago
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
It's a bit complicated, using executeScript() method and some polling, but nicely explained here:
http://www.telerik.com/blogs/cross-wi...
- 132 Posts
- 3 Reply Likes
[code]
//on website opened in inappbrowser
$('a[target="_system"]').on('click', function() {
localStorage.setItem('clicked_link', $(this).attr('href'));
});
//in app
win.addEventListener('loadstop', function() {
win.executeScript({ code: "localStorage.setItem('clicked_link', '');" });
var get_link=setInterval(function() {
win.executeScript(
{
code: "localStorage.getItem('clicked_link')"
},
function( values ) {
var clicked_link=values[0];
if(clicked_link) {
clearInterval(get_link);
win.close();
window.open(clicked_link, '_system');
}
}
);
});
});
[/code]
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
<pre></pre> around the code, you can do a bit. But beware of the tight display width.
Alternatively, make a screen shot from your editor and post it as an image
- 132 Posts
- 3 Reply Likes
- 74 Posts
- 1 Reply Like
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Especially since your code in the other thread is working correctly....you just don't see how, yet.
- 132 Posts
- 3 Reply Likes
Any ideas?
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
- 132 Posts
- 3 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
The setInterval function requires two parameters: (function,interval). Additional parameters are allowed.
Are you sure you are not getting any javascript errors on that piece of code?
- 132 Posts
- 3 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
win.close(), either? Does it get to that point in the code at all?- 132 Posts
- 3 Reply Likes
I have added an alert after "var clicked_link=values[0];" which is shown when opening the IAP. This alert keeps returning ofcourse, but nothing other than that.
- 53 Posts
- 0 Reply Likes
Any help would be appreciatted. Thanks
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
"how would you work arround a googleads
?
Are you saying you want your users to stay away from Google Ads that someone else had placed on their website? If so, do you think either the website owner, or Google, or the end user would like that?
Wouldn't it be better if the user installed an Ad Blocker if he desperately needs to have ads removed from whatever app he is using?
- 53 Posts
- 0 Reply Likes
No third party websites! The reason being is if you open an ad in iOS willopen in the same webview there is no backbutton as there is in Android so the user will have to close the app to clear the ad content and restart the app to get back to my own content if it makes any sense...
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
- 53 Posts
- 0 Reply Likes
Thanks
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
It was my impression, that your PHP script would generate Google ads. The app retrieves the code with Google ads from the server. Then these ads should be filtered out by the time the user gets to see them, so they won't be there.
Then I thought that this would be a bit of a complicated way to not show any ads, and that's why I suggested not to generate them in the first place.
Of course, I couldn't know that you already thought of that possibility, since you never said so.
Just out of curiosity, then: why wouldn't that approach work best?
- 53 Posts
- 0 Reply Likes
- 132 Posts
- 3 Reply Likes
var ref = window.open(url, '_blank', 'toolbarposition=top,location=no');
ref.addEventListener('loadstart', function(e) {
if(e.url.indexOf('system_browser') > -1) {
ref.close();
window.open(e.url, '_system');
}
});
Best part about this: the magic is done within the app and doesn't require much effort from the guy developing the website, just add ?system_browser (or whatever you want) to the link that is supposed to open inside the system browser instead of the inappbrowser.
Having issues with my Windows developer account, so can someone test it with Windows Phone for me?
- 74 Posts
- 1 Reply Like
It will have few issues that can be their like a) If user go back to app then app will relaunch as before opening external browser you have
ref.close(). So user will not able to revert to last page from where he/she has navigated to external link. b) If user want the back stack navigation if he tap back button then which page will be opened ?
I am not sure this will help 100% workaround to make external link in system browser and core app remains unchanged. Please correct me if I mentioned any wrong case.
- 132 Posts
- 3 Reply Likes
- 53 Posts
- 0 Reply Likes
- 132 Posts
- 3 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
The above code is not all that is required. You should start by understanding what is being polled at http://www.telerik.com/blogs/cross-wi...
Then read the first two replies in this thread. At that moment, you will understand what this is about and see what vespino's final code is doing.
"Adding 'system_browser'" is (as I assume) meant as "include this string in the query string of the external web document's URL".
- 53 Posts
- 0 Reply Likes
- 53 Posts
- 0 Reply Likes
- 8 Posts
- 0 Reply Likes
in my app index.html at the bottom I called a new index.js
script src="index.js"
in that index.js I put
win.addEventListener('loadstop', function() {
win.executeScript({ code: "localStorage.setItem('clicked_link', '');" });
var get_link=setInterval(function() {
win.executeScript(
{
code: "localStorage.getItem('clicked_link')"
},
function( values ) {
var clicked_link=values[0];
if(clicked_link) {
clearInterval(get_link);
win.close();
window.open(clicked_link, '_system');
}
}
);
});
});
inline on my webpage before the BODY tag i put
$('a[target="_system"]').on('click', function() {
localStorage.setItem('clicked_link', $(this).attr('href'));
});
then finally the link
a href="HTTP://www.google.com/" target="_system"
does that make sense?
what have I done wrong?
am I even close?
I'm using the right website?
the git
https://goo.gl/gOcwKc
JesseMonroy650 (Volunteer), Champion
- 3325 Posts
- 122 Reply Likes
Your issue is likely unrelated to this.
Related Categories
-
PhoneGap Build
- 15111 Conversations
- 275 Followers






