1
我想從彈出窗口調用父頁面上的函數。我不斷收到錯誤Object doesn't support property or method 'GetValueFromChild'.
我相信錯誤是在彈出窗口中的這一行 - window.top.opener.parent.Xrm.Page.GetValueFromChild(person);
。我嘗試使用window.opener.GetValueFromChild(person);
但仍然得到相同的錯誤。任何幫助深表感謝。這裏的代碼 -從子窗口調用父窗口函數
//parent
$(document).ready(function() {
// This needs to be called from Child window
function GetValueFromChild(person) {
alert(person.Id);
alert(person.Name);
alert(person.Market);
}
});
//parent - jqgrid
colModel: [
{
name: 'Person', index: 'PersonName', width: 70, editable: true, edittype: 'button',
editoptions: {
value: 'Select',
dataEvents: [{
type: 'click',
fn: function (elem) {
var left = (screen.width/2) - (700/2);
var top = (screen.height/2) - (550/2);
var popup = window.open("popup.htm", "popup", "resizable=1,copyhistory=0,menubar=0,width=700,height=550,left='+left+',top='+top");
popup.focus();
}
}]
}
},
//彈出窗口。這個頁面有另一個jqgrid和一個OK按鈕。
$('#btnOK').click(function() {
var person= {
Id: grid.jqGrid('getCell', grid.getGridParam('selrow'), 'Id'),
Name: grid.jqGrid('getCell', grid.getGridParam('selrow'), 'Name'),
Market: grid.jqGrid('getCell', grid.getGridParam('selrow'), 'Market')
};
window.top.opener.parent.Xrm.Page.GetValueFromChild(person); //Error is on this line.
window.close();
});
偉大的作品,謝謝!! – tempid
不錯,謝謝! – fjckls