How to clone existing document in javascript?
<p>Is it possible to create a copy variable of <code>document</code> in <code>javascript</code>?</p>

<p>As I am a C# developer I want something like </p>

<pre><code>var doc=new document();

    var doc = document;
    doc.open('application/txt', 'replace');
    doc.charset = 'utf-8';
    doc.write('Message to write in txt file');
    doc.close();
    if (doc.execCommand('SaveAs', true,'test.txt')) {
        alert(success);
    }
</code></pre>

<p>I have one button and some other controls in the iframe popup where i want to open saveas dialog onclick of button. After i run the above code 'Message to write in txt file' is showing in the page where i have my button and other controls</p>
