user120944
user120944

Reputation:

window.print IE6 and jQuery

For some reason, in Internet Explorer 6, I cannot get window.print(); to actually work within jQuery. Any ideas why this isnt working?

<script> 
 $(document).ready(function(){ 

function print() { 
 window.print(); 
 return false;
} 

$("a#test").click(function() { 
 print(); 
 }); 

 }); 
</script> 

Here is my jsbin: http://jsbin.com/ukoyo/

Also, it seems that window.print(); will not work with Multiple IE.

Upvotes: 0

Views: 2323

Answers (4)

bobince
bobince

Reputation: 536339

Works for me in IE6 on XP SP3.

Multiple IE solutions are generally wobbly. Virtual machines are a much more reliable way to test.

(Note if you have an element with id/name 'print' on the page, IE will incorrectly make ‘window.print’ refer to that element, overriding the method that was previously there.)

Upvotes: 1

meder omuraliev
meder omuraliev

Reputation: 186562

Multiple IEs are totally not the same as the real thing. I would recommend a Virtual machine such as VirtualBox or even Tredosoft's standalone versions.

As for the code I'd do something like this ( your code works though ):

.click(function(e) {
    e.preventDefault();
    print();
});

Upvotes: 0

Rodrigo
Rodrigo

Reputation: 4395

Seems you just redefined the function print(), then calling window.print just called again your own function.

Did you get a "Out of memory" runtime error?

Upvotes: 0

slf
slf

Reputation: 22767

instead of calling a print function that calls window.print try this instead. If it works, you know the problem is somewhere else

$("a#test").click(function() { 
 window.print(); 
});

Upvotes: 0

Related Questions