1. 程式人生 > >JS獲取彈出視窗返回的值

JS獲取彈出視窗返回的值

獲取彈出視窗返回的值

需求:主介面的某項值需要從一個彈出的視窗中取值,如選擇時間

實現:

(1) 主頁面 js

< script type = "text/javascript" >

function fillIds(ids) {

alert( "aaaaaaa===" +ids);

}

</ script >

(2) 主頁面呼叫

<input type="button" onclick="window.open('/tree/product/html/treeOnly.html')" value=" 測試 " />

(3) 呼叫頁面

js

< script type = "text/javascript" >

var url_tree = "/treeMaintain?_method=productTreeOnly" ;

Ext.onReady( function () {

var tree = new koolearn.base.select.Tree( {

width:230,

height:500,

buttons:[

{ text: " 確定 " ,handler: function () {

window.opener.fillIds(tree.getSelects());

window.close();

} ,scope: this }

]

} );

tree.render(document.body);

tree.loadData(url_tree);

} );

</ script >

以上。