"Save image as.." not working in Google Chrome when using window.open() and document.write()
<p>In my app I need to allow a user to right-click on an image to save the image to disk. However, I have noticed that with my particular code, Google Chrome is the only browser that doesn't allow the user to "Save image as.." unless the user first selects <code>Open image in new tab</code> and then, from there, choose to <code>Save image as..</code>.</p>

<p>Since all other major browsers (including Mobile Chrome) work as expected, I'm not sure if I'm not implementing my code in a standard/correct way or if the problem is with Chrome.</p>

<p><strong>Example:</strong></p>

<p>The following HTML is a stripped down version of what I am doing. It will allow you to click a button to open a new window which will contain an image. </p>

<p>To test/confirm the problem I described above, right-click the image and select <code>Save image as..</code> - You should notice that nothing happens. However, if you right-click the image and select <code>Open image in new tab</code>, you will be able to <code>Save image as..</code> from there.</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;script&gt;
        function foo() {
            var tab = window.open();
            tab.document.write('&lt;p&gt;Right-click, then click "Save image as ..."&lt;/p&gt;&lt;img src="http://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png" /&gt;');
        }
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;button onclick="foo();"&gt;Open&lt;/button&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Is this a problem with Chrome or is there another way that I can use <code>window.open()</code> along with <code>document.write()</code> to get Chrome to work like other browsers (i.e. without having to, first, choose <code>Open image in new tab</code>.</p>