Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Interceping a link in a web view

I have a small webview above a larger scrollview, the webview is used to display an image with a link. When the image is clicked the link is opened in the small web view.

Is there a way to intercept this click on the link and open in a new larger webview. The link will always bring the user to the app page so I would like it to go to the app store on the iphone

Is both of these possible?

— asked August 27th 2010 by derek johnston
  • intercept
  • links
  • webview

3 Answers

  • If the small webview loads a local webpage, you could communicate form this to Titanium using events. If you load it from a server is a little more complicated but doable.

    Basicaly you declare in app.js a custom event that opens the bigger webview, and in the small webview you trigger this event what the link it's clicked.

    Why do you use a webview only for an image? you can use the click event on that image. Webviews are costly for the device.

    — answered August 27th 2010 by Dan Tamas
  • Hi,

    I am using just simple webview.html, but the href and src actually call out to adtech(advertising) server that presents an image with a link - this will always be dynamic.

    — answered August 27th 2010 by derek johnston
  • Ok You will have to load the webview from adtech using xhr (the result will be a string), modify it ( add onclick event to the link you want) then set all this as html property to the small webview.

    Painful but doable.

    Hope it makes sense :)

    — answered August 27th 2010 by Dan Tamas
    • Hi,
      got this working thanks for the advice - one problem though is that the link is to the itunes where the user can download the iphone app that is being advertised but I would like my link to go the aoo store install screen for the app. - how do you do that?

      — commented August 30th 2010 by derek johnston
    • Instead of loading the link in the webview, have it open in safari, which will then open the link in the app store. To do that, use:

      I've used this to allow users of my app to buy songs in iTunes.

      Hope that helps,

      Peter Janett

      — commented September 3rd 2010 by Peter janett
    • Thanks peter - got this working

      — commented September 4th 2010 by derek johnston
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.