Javascript 弹出窗口:在DOM中插入jQueryAjax响应(无document.write)
我正在使用Javascript 弹出窗口:在DOM中插入jQueryAjax响应(无document.write),javascript,jquery,ajax,popupwindow,Javascript,Jquery,Ajax,Popupwindow,我正在使用 var preview = function () { $.ajax({ type: "POST", url: myAction.do, data: "id=" + myid, success: function (response) { // some code var x=window.open('', '_blank', 'titlebar=no,scrollbars=yes,menubar=
var preview = function () {
$.ajax({
type: "POST",
url: myAction.do,
data: "id=" + myid,
success: function (response) {
// some code
var x=window.open('', '_blank', 'titlebar=no,scrollbars=yes,menubar=no,height='+height+',width='+width+',resizable=yes,toolbar=no,location=no,location=0,status=no,left='+left+',top='+top+'');
x.document.open();
x.focus();
x.document.write(response);
return false;
},
error: function () {
return false;
},
});
};
响应是一个完整的html页面
因为我需要在其中执行javascript/jquery脚本,所以我需要使用不同的方法在x.document中编写响应
编辑
在Firefox26.0和Chrome32.0.x上,我通过使用
x.document.close();
之后
x.document.write(replace);
相反,在IE上,所有包含的.js脚本都被忽略。
编辑2
我决定
<body onload="myload()">
在我的jsp中,我定义了myload(),在其中我调用脚本。@BlackSheep:对不起,我误解了你对我的另一个问题的评论。“无限”是什么意思?无可奉告?对不起,我不该写那个。关于您当前的问题,为什么不打开一个url,将ID作为查询参数读取?这样就不需要使用Ajax了。这个问题似乎离题了,因为它太本地化了