Window.print doesn't work in IE
You MUST do a mywindow.document.close()
and you may NOT have a space in the window name
I assume you invoke PrintElem from onclick of something - if that something is a link, you need to return false in the onclick handler!
Here is how I would do it if I had to
function PrintElem(elem) {
Popup($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'to_print', 'height=600,width=800');
var html = '<html><head><title></title>'+
'<link rel="stylesheet" href="css/mycss.css" type="text/css" />'+
'</head><body onload="window.focus(); window.print(); window.close()">'+
data+
'</body></html>';
mywindow.document.write(html);
mywindow.document.close();
return true;
}
but I am not sure whether or not the window.close() will interfere with the printing
And why not
$(function() {
$('#print_it').click(function(){
popup($('#itinerario').html());
});
});
IE11 Windows 7 Print issue after kb4021558
Update:
Microsoft have now released a patch: Microsoft IE patch
Just wanted to summarise the workarounds I've found and which have been posted here.
1) If you are using your own print button change to use document.execCommand('print', false, null);
. Test support using document.queryCommandSupported('print')
and call window.print()
if not supported (Prob just Firefox)
2) Use Print Preview. Additionally select the part of the page to print, right click and select print preview. Then select As selected on screen
.
3) Use another browser like Chrome
4) Uninstall the update
5) Wait for Microsoft fix. Their KB page KB Link has been updated with this as a known issue. Therefore you assume a fix is on the way.
Related Topics
Array.Length Is Zero, But the Array Has Elements in It
How to Stop a Window.Setinterval in JavaScript
Clearrect Function Doesn't Clear the Canvas
Check If Jquery Has Been Loaded, Then Load It If False
What Does Arrow Function '() => {}' Mean in JavaScript
How to Convert JSON Object to JavaScript Array
Undefined Values in Array(Len) Initializer
How to Remove a Key from a JavaScript Object
Does Console.Log Invokes Tostring Method of an Object
How to Rotate a 3D Object on Axis Three.Js
What Is This Practice Called in JavaScript
How to Determine If an Image Has Loaded, Using JavaScript/Jquery
How to Get a JavaScript Object Property Name That Starts with a Number
JavaScript Audio Play on Click
Npm Install Cannot Find Module 'Semver'
What Are the Actual Uses of Es6 Weakmap