Javascript window.print() not recognizing window object
<p>I am trying to provide a button to open a browser level print dialog on a window. I first tried window.print(); with an inline "onclick" on an <code>&lt;input&gt;</code> and then a click() function on the input using jQuery, and both give the same error when clicked:</p>

<blockquote>
  <p>TypeError: Property 'print' of object [object global] is not a function</p>
</blockquote>

<p>I should point out that this is a popup window, but I wouldn't have thought that would matter except that any form of using window.print() on the parent page works fine.</p>

<p>Seemed like something must be happening to the window object somewhere, so I did the following in console:</p>

<p><strong>window.name</strong></p>

<p>"JOIN"</p>

<p><strong>window.self</strong></p>

<p>Window {top: Window, window: Window, location: Location, external: Object, chrome: Object…}</p>

<p><strong>window.location</strong></p>

<p>Location {assign: function, replace: function, reload: function, ancestorOrigins: DOMStringList, origin: "http://local.xxx.xxx:8080"…}</p>

<p>So it SEEMS like the window object is there and defined as expected.</p>

<p>I can even run other methods like close(), confirm(), alert(), scrollTo(), etc on this same window object and they work fine. So why wouldn't print()?</p>

<p>The contents of the page don't seem to matter, and I will also say we are not using iFrames or frames. I did replace ALL the content of the popup with just</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&gt;&lt;/head&gt;
&lt;body&gt;Foo&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>with the same results. So I'm fairly certain none of our other code is interfering.</p>

<p><strong>EDIT</strong></p>

<p>The code that I was using to trigger print():</p>

<pre><code>$('.foobar').click(function(){
    window.print();
});
</code></pre>

<p>tho now I'm just doing it in console.</p>

<p>The button</p>

<pre><code>&lt;input type="button" class="foobar" value="Print" /&gt;
</code></pre>
