Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  11] [ 6]  / answers: 1 / hits: 35428  / 12 Years ago, fri, september 7, 2012, 12:00:00

I'm trying to pass a DIV to a new window.



JavaScript



function openWin() {
myWindow=window.open('','','width=200,height=100');
}


HTML



<div id=pass>pass this to the new window</div>
<a href=# onclick=openWin();>click</a>


Can someone help me out?


More From » popup

 Answers
42

I think you want this:



var divText = document.getElementById(pass).outerHTML;
var myWindow = window.open('','','width=200,height=100');
var doc = myWindow.document;
doc.open();
doc.write(divText);
doc.close();


(Demo at jsfiddle.net)


[#83202] Wednesday, September 5, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
terrence

Total Points: 120
Total Questions: 115
Total Answers: 87

Location: England
Member since Fri, May 22, 2020
4 Years ago
terrence questions
Sat, Jun 5, 21, 00:00, 3 Years ago
Wed, Jun 17, 20, 00:00, 4 Years ago
;