| |

VerySource

 Forgot password?
 Register
Search
View: 2481|Reply: 11

About printing

[Copy link]

2

Threads

13

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-3-4 07:30:01
| Show all posts |Read mode
javascript
How to print in landscape orientation?
Header and footer are not printed, only a part of the page is printed.
Grateful
Reply

Use magic Report

0

Threads

64

Posts

45.00

Credits

Newbie

Rank: 1

Credits
45.00

 China

Post time: 2020-5-16 11:15:01
| Show all posts
function PreviewReferralPrint ()
            {
                 bdhtml = window.document.body.innerHTML;
                 sprnstr = "<!-startprint->";
                 eprnstr = "<!-endprint->";
                 prnhtml = bdhtml.substr (bdhtml.indexOf (sprnstr) +17);
                 prnhtml = prnhtml.substring (0, prnhtml.indexOf (eprnstr));
                 window.document.body.innerHTML = prnhtml;
                 window.print ();
                 window.parent.returnValue = '0'; window.parent.close ();
            }

<!-startprint->
Write the HTML to be printed here
<!-endprint->
Reply

Use magic Report

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-7-5 09:45:01
| Show all posts
Awesome
Reply

Use magic Report

2

Threads

13

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-7-9 23:30:01
| Show all posts
Is there a way
Print a part of this page without popping up a new page?
(Is it a bit demanding)
Reply

Use magic Report

2

Threads

13

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-7-10 10:15:01
| Show all posts
How can you fight horizontally?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-10 11:30:02
| Show all posts
Use css media to specify print content
Reply

Use magic Report

2

Threads

13

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-7-10 21:15:01
| Show all posts
Cry
Who will tell me how to fight?
Reply

Use magic Report

0

Threads

26

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-7-24 23:00:01
| Show all posts
For horizontal printing, you can change the print settings, but it seems that horizontal printing cannot be modified with javascript, but it may be related to the browser version and operating system. Mine does not work anyway. You can try it. You can modify the "HKEY_CURRENT_USER->" The orientation item in "SoftWare->Microsoft->Internet Explorer->PageSetup" is used to control the direction of printing. The value may be 1 or 2. You can change it and try.
Reply

Use magic Report

2

Threads

13

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-8-2 04:45:01
| Show all posts
javascript can not be set
gosh
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-9 00:00:02
| Show all posts
<HTML><HEAD><TITLE>Web printing removes the header and footer, and the page elements that do not want to be printed</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=javascript>
function printpr() //Preview function
{
document.all("qingkongyema").click();//Remove the header and footer before printing
document.all("dayinDiv").style.display="none"; //Hide the elements that you do not want to print before printing (in this example, hide

Hide two buttons "Print" and "Print Preview")
var OLECMDID = 7;
var PROMPT = 1;
var WebBrowser ='<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-

11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
document.all("dayinDiv").style.display="";//Display the element after printing (showing "printing" and "printing pre

"View" two buttons, convenient for others to print next time)
}
function printTure() //Print function
{
    document.all('qingkongyema').click();//Same as above
    document.all("dayinDiv").style.display="none";//Same as above
    window.print();
    document.all("dayinDiv").style.display="";
}
function doPage()
{
    layLoading.style.display = "none";//same as above
}

</SCRIPT>

<script language="VBScript">
dim hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"
'//Set the header and footer of web page printing to be empty
function pagesetup_null()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
end function
'//Set the header and footer of web page printing as default values
function pagesetup_default()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key, "&w&b page number,&p/&P"
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d"
end function
</script>

</HEAD>
<BODY background="images/background_01.gif" leftMargin=0
topMargin=0 rightMargin=0 bottomMargin=0 style="BACKGROUND-POSITION: center 50%">

<DIV align=center>

What you want to print..........
</DIV>

<DIV align="center" id="dayinDiv" name="dayinDiv"><input type="button" class="tab" value="打

印" onclick="printTure();">&nbsp;&nbsp;
<input type="button" class="tab" value="Print Preview" onclick="printpr();">
<input type="button" name="qingkongyema" id="qingkongyema" class="tab" value="clear page number"

onclick="pagesetup_null()">&nbsp;&nbsp;
<input type="button" class="tab" value="Restore page number" onclick="pagesetup_default()">
</DIV>

</BODY>
</HTML>
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list