incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Lunny <alu...@gmail.com>
Subject Re: API function: Open url in system web browser
Date Fri, 18 May 2012 18:18:45 GMT
On 18 May 2012 10:58, Brian LeRoux <b@brian.io> wrote:

> > * not cross-platform, and will never work on Android 2
>
> why not?
>

Links go through this method:
http://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String)

The target is not passed to loadUrl.


>
> > * doesn't really work on iOS - iOS can't access the value of the target
> > attribute, so it's just checking whether "target" is set. Shaz has more
> > details in the JIRA issue referenced above
>
> could we not walk the dom in the cordova.js, find elements w/ target
> _blank and then add a url param for ios native to intercept?
>

That would be brittle and error prone.

If you're terrified of adding a single function to the public API, a
feasible solution would be to use event capturing, which would at least
have the benefit of working with dynamic content:

document.addEventListener('click', // and touchstart, touchend, etc
function (e) {
  if (e.target.tagName == 'A' && e.target.getAttribute('target') ==
'_blank') {
    e.preventDefault();
    navigator.app.loadUrl(e.href, {openExternal: true});
    return false;
 }
}, true);

How this is more elegant or useful than exposing the loadUrl function, that
would  be called anyway, is beyond me, but yes, we could magically make
target="_blank" work. That doesn't solve the problem of needing the loadUrl
call to do the right thing.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message