0

hi i try to do printing a page but it must open the page first in a new tab. i have try to make the code. from my code i can open the page in a new tab but the print function do a print a blank page not the page that i direct open in a new tab.

how to fix that? please help me

this my code

<script>
 function myFunction() {
    w=window.open("../../192.168.1.22/print_page/SPL_Karyawan.html");
 w.print();
 w.close();
 }
 
 </script>
Minervaz Mine
  • 273
  • 1
  • 3
  • 17

1 Answers1

1

Below code is working for mine.

<html>
<head>
<script type="text/javascript">
function openNewWindow(){
var newWindow=window.open('redir2.html');
newWindow.focus();
newWindow.print();
newWindow.close();
}
</script>
</head>
<body>

<input type="button" value="Open new window" onclick="openNewWindow()" />

</body>
</html>

Source: http://jsfiddle.net/Q5Xc9/1/

Based on the comment, Given path in the window.redirect is wrong. It should be start with IP address with http.

Tamilvanan
  • 708
  • 1
  • 7
  • 21