Windows.print () Creating a blank page before pages
source link: https://www.codesd.com/item/windows-print-creating-a-blank-page-before-pages.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Windows.print () Creating a blank page before pages
I'm using the following javascript to print a page then I want to redirect after either canceling or accepting the print.
<script type="text/javascript">
window.print();
window.location.replace("URL");
</script>
Everything works but when I add the window.location it adds a full blank page before the pages I'm printing.
you need to add a property in CSS @page{margin:0}
you can try this code :
<!DOCTYPE html>
<html>
<head>
<title>tp</title>
<style type="text/css">
@page{
margin: 0mm;
}
*{
padding: 0;
margin: 0;
background: red;
}
</style>
</head>
<body>
<p>test</p>
<script type="text/javascript">
window.print();
window.location.replace("http://www.google.com");
</script></body>
</html>
Related Articles
Javascript window.open (xxx, & ldquo; download & rdquo ;;) creates a blank page at the download prompt
windows.print results in empty page
Body onload creates a blank page
JavaScript window.print () gives a blank print
Javascript window.print () gives a blank preview
Firefox prints an extra blank page
Silverlight HTML Bridge printing windows.print () white pages
Empty page when & ldquo; Print at the bottom of the page & rdquo; is activated and all sections of the blank page are deleted
Css layout - second blank page when printing
Elimination of the local ratio of additional blank pages
How do I delete blank pages in SQL Reports?
By calling $ window.print () in angularjs, the print preview displays a blank page
Chrome displays a blank page on the RTL language site until the window is resized
Crystal Reports Printing blank page
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK