gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 08:19:13 25 4
gpt4 key购买 nike

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com