Click to See Complete Forum and Search --> : print css on external files
I have a print button in the page
<center><script>
document.write("<input type='button' " +
"onClick='window.print()' " +
"class='printbutton' " +
"value='Print This Page'/>");
</script>
</center>
I can call <style type="text/css" media="print">
.printbutton {
visibility: hidden;
display: none;
}
body{
font-size: 15px;
font-family: Arial, Helvetica, sans-serif;
margin-left:0.5em;
margin-right:0.5em;
}
</style> but when this part of code be put on external an call it ,it did not work , why
<link href="css/print.css" media="print" rel="stylesheet" type="text/css" />
I have print able web form , need to decide where to break the page , but on Ie the shrink to fit is different with firefox , I add <style type="text/css" media="print">
body{
font-size: 15px;
font-family: Arial, Helvetica, sans-serif;
margin-left:0.5em;
margin-right:0.5em;
}
</style> in my web page , but still Shink to fit is different in these two browns .
is that possible to set the stand margin whatever the user use what kind of browns or print setting???:(
You can not change the page margin for printing. Do not confuse this with body margin, which is completely different.
thank you,
How about put on external??
<center><script>
document.write("<input type='button' " +
"onClick='window.print()' " +
"class='printbutton' " +
"value='Print This Page'/>");
</script>
</center>
Why are you using an inline script to add html? It makes no sense.
Then , what is the best way to handle this?
What is wrong with html? No need for JavaScript.
rnd me
12-17-2009, 12:07 AM
What is wrong with html? No need for JavaScript.
html alone would present a non-working button to anyone without javascript, wheras a javascript-added button would only present a button if the button would work as expected when clicked...
that said, i would typically set an id on the input (perhaps btnPrint), and hide it in css by default ( #btnPrint {display:none;}).
then, anywhere in javascript, even an external file, i can say:
document.getElementById("btnPrint").style.display="inline";
this is almost as good as actually adding the button in javascript, usability-wise.
The only problem with un-hding it in js it when someone has no javascript or css available, the busted button would show up. that's probably a small % of users, and they can always use the browser's print feature...