主界面上通过ajax返回的html字符串,然后怎么进行弹出新页面进行展示这个html,html字符串是动态生成的。 好像通过iframe可以解决但不知道怎么下手。
$.ajax({
url: '…………',
success: function(resp){
var newWin = window.open('', '_blank');
newWin.document.write(resp);
}
});
不需要ajax,直接用window.open('url', '_blank');加载你的地址就可以了
$.ajax({
url: "./xxxx/123.html",
type: "GET",
dataType: "text",
success: function (data) {
var ow = window.open();
ow.document.write(data);
ow.document.clear();
}
});
要注意在返回的html字符串中,需要加载的css和js文件地址或超链接的url地址都要写成相对于当前页面的相对地址,不要写成相对于123.html的相对地址。