<button type="button" onClick="window.location.href='http://mywebsite.com';window.print();return false;">Print</button>
Above works but I want to print first, then have a short delay and then send the user to the specified page.
I tried this without success:
<button type="button" onClick="setTimeout('window.location.href='http://mywebsite.com', 100);window.print();return false;">Print</button>
this code requires jquery http://jquery.com/
Please note that setTimeout() is in milliseconds, and a delay of 100 ms will not be noticeable by the user.
<button type="button" id="print_button">Print</button>
<script>
$().ready(function() {
$(document.getElementById('print_button')).click(function() {
window.print()
setTimeout(function() {
window.location.href = 'http://mywebsite.com'
}, 5000)
return false
})
})
</script>
Try this code, this is the same code you have used, i have just edited it
<button type="button" onClick="setTimeout('window.location.href=\'http://www.google.com\'', 3000);window.print();return false;">Print</button>
this is worked for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.