Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening new window

Status
Not open for further replies.

cajchris

Programmer
Oct 13, 2005
57
GB
when i click a link to open a new window, how can i copy the <body> contents from the original window into this window

regards
cajchris
 
well, wouldn't it be easier to just open the same page in a new window? anyway, i suppose you could do something like this:

Code:
function openIt() {
    var w = window.open('','w','');
    var h = document.getElementsByTagName("body")[0].innerHTML;
    with (w.document) {
        open();
        writeln('<html><head><title>title</title></head><body>');
        writeln(h);
        writeln('</body></html>');
        close();
    }
}

Code:
<a href="#" onclick="openIt();return false;>Click Me</a>


** - untested.

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top