【发布时间】:2013-02-10 18:38:45
【问题描述】:
我一直在研究如何打开一个新窗口并使用 jQuery/JavaScript 将 HTML 写入其中,似乎正确的方法是:
为新窗口创建一个变量
var w = window.open();
插入新数据并处理变量
$(w.document.body).html(data);
对我来说,这完全有道理。但是,当我尝试将其合并到我的脚本中时(“数据”是 HTML 的持有者),它不会打开一个新窗口......除非我只是错过了一些简单的东西,据我所知它看起来很棒。 ..
function newmore(str) {
var identifier = 4;
//get the history
$.post("ajaxQuery.php", {
identifier : identifier,
vanid : str
},
//ajax query
function(data) {
//response is here
var w = window.open();
$(w.document.body).html(data);
});//end ajax
}
有什么想法吗?
附:控制台中似乎没有错误
【问题讨论】:
-
请不要使用弹出窗口。它们通常很烦人,即使是应要求打开 - 请考虑使用内联“窗口”。
-
它是用来展示一家公司的历史的,相信我我也不喜欢它,但是我又不付账了。 :)
标签: javascript jquery ajax new-window