Venkat Janyavula
Venkat Janyavula

Reputation: 625

How to update child window?

I have already opened child window by following code

var myWindow = window.open('','','width=1250,height=1000,resizable=yes,fullscreen=yes');
var doc = myWindow.document;
doc.open();
doc.write(divText);
doc.close();

now I am trying to update the html of that already opened myWindow. How will I be able to do that?

Upvotes: 0

Views: 446

Answers (2)

Marco Bonelli
Marco Bonelli

Reputation: 69367

You don't need to do doc.open() and doc.close().

You can do the following:

var myWindow = window.open('','','width=1250,height=1000,resizable=yes,fullscreen=yes');
var doc = myWindow.document;
doc.body.innerHTML = divText;

// Then, when you want, change it:
doc.body.innerHTML = "Something else";

Upvotes: 2

Yaje
Yaje

Reputation: 2831

Try

DEMO

$("#sd").on("click",function(){
var myWindow = window.open('','','width=1250,height=1000,resizable=yes,fullscreen=yes').document.write("DDD");
});

use document.write() to add text on your newly created window.

Upvotes: 1

Related Questions