我想調用下面的函數來創建一個彈出的新窗口。無論何時,我都在調用它在chrome中崩潰父窗口。試圖在window.open後從父窗口調用子窗口函數
我觀察到:直到openDoctorDetails函數被執行,子窗口根本沒有加載。因爲doctorDetailsPage.populateDoctorDetails
從未被定義。因此,它將陷入無限循環。
var openDoctorDetails = function(physicianId) {
var time1 = new Date();
var doctorDetailsPage = window.open('PhysicianDetails.html', '_blank',
'resizable=yes; width=1000; height=1500; top=50; left=50');
var times = 0;
while (!doctorDetailsPage.populateDoctorDetails) {
setTimeout(function() {
times++;
}, 500);
}
doctorDetailsPage.populateDoctorDetails(physicianId);
doctorDetailsPage.focus();
console.log("Time taken for this openDoctorDetails:" + (new Date() - time1)
+ " " + times);
};
http://stackoverflow.com/questions/13311812/popup-window-accessing-parent-dom – Mikes3ds