Titanium Community Questions & Answer Archive

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

Click button and open hyperlink in SAFARI instead of webview

Is it possible to push a button and open safari with the hyperlink ?

I do it now with a webview and it works but when I enlarge the characters it is not very good readable.

var b1 = Titanium.UI.createButton({
title:'www.soft4u.be',
height:40,
width:130,
left: 20,
top:320
});
var visible=true;
b1.addEventListener('click', function()
{

var w = Ti.UI.createWindow();
w.orientationModes = [
    Titanium.UI.PORTRAIT,
    Titanium.UI.LANDSCAPE_LEFT,
    Titanium.UI.LANDSCAPE_RIGHT
];

var webview = Ti.UI.createWebView();

webview.url = 'http://www.soft4u.be';

// webview.scalesPageToFit = true;

w.add(webview);

win.tab.open(w);    
});

win.add(b1);

— asked April 3rd 2010 by Johan Pyfferoen
  • button
  • hyperlink
  • safari
  • webview
0 Comments

1 Answer

  • Accepted Answer

    you'll want to use Titanium.Platform.openURL()

    so…

    //create label (or button etc)
    var label = Ti.UI.createLabel({text:'LINK'});        
    
    //event listener
    label.addEventListener('click', function(e)
    {
    //open link in safari - application will close
    Titanium.Platform.openURL('http://www.soft4u.be');
    });
    
    — answered April 3rd 2010 by Steve Burtenshaw
    permalink
    2 Comments
    • Thanks a lot Steve!! Just what I needed. ;)

      — commented December 30th 2011 by José Júnior
    • Perfect! Thanks.

      — commented May 22nd 2014 by mario rossi
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.