我創建一個彈出如下:,彈出的DOM元素的jQuery操縱
var comet = {
popup: null,
newPopup: function(windowsname, w, h){
this.popup = window.open(windowsname, windowsname, 'width=' + w + ',height=' + h);
var self = comet;
var logOut= null;
$(this.popup.document).ready(function(){
logOut = self.popup.document.getElementById('logout');
console.log(logOut);
$(logOut).live('click', function(){
alert('HELLO');
return false;
})
})
},
some_function: function(){
//calling it here:
this.newPopup('index.php',1120,550);
}
}
的logOut
有時(通常是開放的第一窗口)返回null。此外,點擊處理程序永遠不會通過,並且原始點擊處理程序運行。
如何覆蓋彈出窗口的實際點擊處理程序?
這兩個網頁上我的網站,所以應該不存在跨站點的問題..
這裏是一個小提琴,顯示了一點什麼,我試圖做的:http://jsfiddle.net/maniator/K2B3q/
@Matt,對不起,添加到我的問題。 'comet'是對象名稱 – Neal 2011-05-12 21:10:02
爲什麼不包括你想在彈出的index.php文件本身的彈出頁面上操作的JS,而不是在主文檔中? – maxedison 2011-05-12 21:11:50
@maxedison,我想讓主頁面(創建彈出窗口)知道'logOut'被點擊了 – Neal 2011-05-12 21:12:40