Our website has a feature that allows you to print a member profile. The way it works is that the javascript function is attached to the button via onsubmit. The javascript function uses window.open to reopen the page in a special mode that updates the printable version of the page. A.
This functionality has existed since 2008 and works in all browsers. After about a week or so, it stops working in Chrome. In Chrome, what happens is that an open window opens, but then a small empty window opens, and then they all close.
In search of a discussion of this problem, I could not find the exact problem, but found something that said that onsubmit should add "return false". I tried to add this, but that did not help.
Here is what onsubmit looks like:
<button onclick="PrintEmailSubmit('print');">Print Profile</button>
Here is the code that opens the window:
window.open('print-email-profile.php?mode=' + mode,'','width=' + width + ',height=' + height + ',scrollbars=yes,location=0,menubar=1,status=0,toolbar=0')
While there is no need to see, here is the whole PrintEmailSubmit () function:
function PrintEmailSubmit(mode) { var width; var height; switch(mode) { case 'print': width = 850; height = 1000; break; case 'email': width = 400; height = 120; break; default: alert('Error: invalid calling sequence -- should not happen!'); exit; } window.open('print-email-profile.php?mode=' + mode,'','width=' + width + ',height=' + height + ',scrollbars=yes,location=0,menubar=1,status=0,toolbar=0'); }
And finally, what makes this work so that the special version of the page has the following body tag:
<body onload="window.print();window.close();">
As stated above, the function continues to work in IE and Firefox. This problem occurs with Chrome.
Any ideas?