2012-06-15 42 views
0

我一直在嘗試在sencha touch中編寫代碼,它有一個按鈕,當我點擊它時,它應該在新窗口中彈出一個網頁。在新窗口中打開網頁的工作方法?

  1. Window.open() - 我不能使用這種方法,因爲它不phones.Though做工精細 我意識到這是打開一個新的瀏覽器 窗口中最簡單的方法。

  2. document.location.href = url - 此方法在同一頁面打開URL,但我希望它在彈出的窗口中打開。

是否有任何其他方式,當用戶點擊一個按鈕,一個新窗口中打開一個頁面,下面是我的代碼

Ext.application({ 
    name: 'Opening new page', 

    launch: function() { 
     Ext.create("Ext.tab.Panel", { 
      fullscreen: false, 
      items: [ 
       { 
        xtype: 'button', 
        text: 'click to open google', 
        ui: 'confirm', 
        handler: function() { 
         document.location.href=("http://www.google.com/"); 
        } 
       } 
      ] 
     }); 
    } 
}); 
+0

爲什麼不使用Ext.window? – ijse

+0

你能給我一個在按鈕事件中使用Ext.window的好例子嗎? –

回答

0

請試試這個代碼:

handler: function() { 
    var link = Ext.getDom('hidden_link'); 
    link.href = 'http://www.google.com'/; 
    var clickevent = document.createEvent('Event'); 
    clickevent.initEvent('click', true, false); 
    link.dispatchEvent(clickevent); 
} 
+0

它不起作用!當我把它放在處理程序函數中時什麼也不顯示! –

+0

或者你可以嘗試下面的代碼:a new window

0
-1

在你的工作頁面創建一個彈出窗口(一個簡單的窗口),並使其知名度假。當你點擊按鈕,其知名度更改爲true,並給予重點吧.. 也可以打開在彈出的窗口中什麼..

,或者您可以使用此jQuery代碼

$(document).ready(function() { tb_show(title, "testpage.aspx?id=" + url + "&TB_iframe=true&width=700&height=600", null); }); 

在這裏你可以傳遞你想要的參數。這將打開一個新的彈出窗口。

+0

我正在尋找一個sencha觸摸應用程序,這項工作? –

+0

第一個(創建一個彈出窗口並將其可見性設置爲false)將起作用。我相信這一點..但我不知道第二個想法是否可行。 –

0

嘿@coding可以說是覆蓋是一種彈出,試試這個爲處理事件,

var overlay = new Ext.Panel({ 
    floating : true, 
    modal : true, 
    centered : true, 
    width : 500, 
    height : 500, 
    styleHtmlContent : true, 
    html: '<div><iframe style="width:100%;height:100%;" src="http://www.sencha.com/products/touch">Your device does not support iframes.</iframe></div>', 
}).show('pop', true) 

並請使用你的大腦,我不,我可以做你的功課 。我希望這有幫助。 :) Ciao enter image description here

+0

它不工作@hekomobile! :(。我仍然沒有找到更好的解決方案,這個簡單的問題!希望我能得到一個 –

+0

告訴我你怎麼做。我不知道 – hekomobile

+0

{items:[{xtype:'button',text:'點擊打開', handler:function() var overlay = new Ext.Panel({float:true,modal: ('pop',true),true,center:true,width:500,height:500,styleHtmlContent:true, html:'http://google.com/', items:[], } ; } }]});}}); –