Button Opens Webview and Url

You must Login before you can answer or comment on any questions.

I'm stuck with having a button open a new window that shows a full url (http://mysamplesite.com).

var b1 = Titanium.UI.createButton({
    image:'images/site.png',
    width:160,
    height:95,
    top:10
});
b1.addEventListener('click', function()
{
        var win = Ti.UI.createWebView({
            url:'http://mysamplesite.com',
            title:'My Site',
            height:'auto',width:'auto'
        });
        Titanium.UI.currentTab.open(win,{animated:true});
});
 
win.add(b1);
Any ideas?

— asked 2 years ago by Joe Spano
0 Comments

2 Answers

There is some time since the windows don't open a web url anymore. Try like this:

var b1 = Titanium.UI.createButton({
    image:'images/site.png',
    width:160,
    height:95,
    top:10
});
b1.addEventListener('click', function()
{
        var win2 = Ti.UI.createWebView({
            title:'My Site',
            height:'auto',width:'auto'
        });
 
        var webview = Titanium.UI.createWebView({
            url:'http://mysamplesite.com',
        });
 
        win2.add(web_view);
 
        Titanium.UI.currentTab.open(win2,{animated:true});
});
 
win.add(b1);

Just figured it out. It should be createWindow first, then createWebView

b1.addEventListener('click', function()
{
        var win2 = Ti.UI.createWindow({
            title:'My Site',
            height:'auto',width:'auto'
        });
 
        var webview = Titanium.UI.createWebView({
            url:'http://mysamplesite.com',
        });
 
        win2.add(web_view);
 
        Titanium.UI.currentTab.open(win2,{animated:true});
});

Your Answer

Think you can help? Login to answer this question!