52,787
社区成员




function saveOperate(unid,id,fornname,sAction)
{
var path = GetCurrentdbUrl();
var btid =id;
path = path+"/agtOperateSave?OpenAgent&btid="+btid+"&fornname="+fornname+"&unid="+unid;
$.ajax({
url: path,
type: 'get',
dataType: 'text',
async: true,
error:function(){
alert('error');
},
success:function(text){
if(text.indexOf("OK")!=-1){
eval(sAction)
}else{
alert(text);
}
}
});
}
//SAction如下:
function openModelDialog(url,x,y,title){
/* url: 打开的url
x: 横向宽度
y: 纵向长度
sAction:返回后执行的函数
*/
var strUrl = GetCurrentdbUrl() + "/fomModelDialog?OpenForm&Title="+escape(title)+"&Action=&Src=" +url;
if(x < screen.width){
width = x;
}else{
width = screen.width;
}
if(y < screen.height){
height = y;
}else{
height = screen.height;
}
var vRtn = showModalDialog(strUrl, window, 'help:no; status:no; scroll:no; dialogWidth:'+width+'px; dialogHeight:'+height+'px');
if (vRtn){
if(sAction != ""){eval(sAction(vRtn));}
}
}
问题:
1、提示出错就在openModelDialog()函数调用showModalDialog这一行,提示对象不支持此属性和方法。
2、该代码在我个人电脑上调试可以正常运行,在执行完后台成功后,成功打开一个模态窗口。
3、在客户机和公司其他同事电脑上均报错。
运行环境为:IE8
疑问:
1、是不是jQuery Ajax回调函数对内容有所限制?
2、是IE8安全级别提高后,不允许回调函数中打开模态对话框?
最后换了种解决方式:
1、修改saveOperate函数,在返回OK后,设置修改全局变量checkYeWuflag=true
2、在调用saveOperate函数后,对全局变量判断true是执行openModelDialog()函数
关键代码如下:
var checkYeWuflag=false; //查看业务信息参数
function saveOperate(unid,id,fornname)
{
var path = GetCurrentdbUrl();
var btid =id;
path = path+"/agtOperateSave?OpenAgent&btid="+btid+"&fornname="+fornname+"&unid="+unid;
$.ajax({
url: path,
type: 'get',
dataType: 'text',
async: false,
error:function(){
alert('error');
},
success:function(text){
if(text.indexOf("OK")!=-1){
checkYeWuflag=true;
}else{
alert(text);
}
}
});
}
if(checkYeWuflag) openModelDialog();