简体   繁体   中英

How can I add content to a page after opening the link in a new window/tab?

I'm trying to add some content into a page that is opened in a new tab/window, and nothing seems to be happening. Here is some of my code:

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

Any ideas?

as you have tagged jquery:

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

Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM