基本上,我有一個頁面,其中包含一個javascript
文件。在js文件 我有兩個功能稱爲功能a()
和功能b()
。內函數「A」我調用彈出來加載。加載子彈出後,我有一個稱爲交互的函數,它會調用ajax
。如果結果爲真,我需要關閉子頁面,然後在主頁面中調用函數「B」。下面是示例代碼。問題是我不能在子頁面中引用函數「B」並調用主頁面。關閉子頁後刷新主頁
function a() {
var strWindowFeatures = "location=yes,scrollbars=yes,status=yes";
var URL = path of the url
var win = window.open(URL, "_blank", strWindowFeatures);
}
function b() {
calling a
function to relaod the page. //
}
function InterActive(encodeText) {
url: url
cache: false,
async: false,
type: 'GET',
contentType: 'application/json; charset=utf-8',
data: {},
dataType: 'json',
success: function (data) {
if (data === true) {
alert('record updated');
window.close();
// i need to call the function b() in the child page..
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR);
alert(textStatus);
alert(errorThrown);
}
});
所以你打開一個新窗口? –
是的。在關閉彈出窗口之前的子窗口中,我需要調用主窗口中的函數 –
爲子窗口添加一個'onbeforeunload'事件處理程序,用於調用重載功能 – Icepickle