javascript - 在新窗口/选项卡中打开链接后如何将内容添加到页面?

标签 javascript jquery html

我正在尝试将一些内容添加到在新选项卡/窗口中打开的页面中,但似乎没有发生任何事情。这是我的一些代码:

var newWindow = window.open('/Window');
newWindow.document.body.innerHTML += '<div>This is a test</div>';

有什么想法吗?

最佳答案

因为您已标记 jquery:

var w = window.open();
var html = '<div>This is a test</div>';
$(w.document.body).html(html);

<强> Demo

关于javascript - 在新窗口/选项卡中打开链接后如何将内容添加到页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23202382/

相关文章:

javascript - jQuery 表单验证与电子邮件检查功能冲突

javascript - jQuery 在循环中注册事件

html - 鼠标悬停在整个页面上的问题

javascript - Onclick 按钮在页面加载时自动运行

javascript - 哪个逻辑运算符优先

javascript - 如果提交处理程序返回 true,则 jQuery show() 函数不会在 Safari 中执行

javascript - 带有 setInterval 且不带任何参数的回调函数

jquery - 将滚动上的 ul 样式更改为 div

javascript - 使用express查找单个mongodb文档

javascript - 什么是纯 HTML5 应用程序?