当我打电话OpenModelWindow
时,功能显示错误fun is not a function
这里是我的功能代码
function OpenModelWindow(url, option) {
var fun;
try {
if (parent != null && parent.$ != null && parent.$.ShowIfrmDailog != undefined) {
fun = parent.$.ShowIfrmDailog
}
else {
fun = $.ShowIfrmDailog;
}
}
catch (e) {
fun = $.ShowIfrmDailog;
}
fun(url, option);
}
答案 0 :(得分:0)
那是因为fun
可能是未定义的。要解决此问题,请检查fun
的类型:
function OpenModelWindow(url, option) {
var fun;
try {
if (parent != null && parent.$ != null && parent.$.ShowIfrmDailog != undefined) {
fun = parent.$.ShowIfrmDailog
}
else {
fun = $.ShowIfrmDailog;
}
}
catch (e) {
fun = $.ShowIfrmDailog;
}
if (typeof fun == 'function') // <----
fun(url, option);
}