How to print a webpage in two columns or one column as per the user input/cho开发者_JS百科ice.
And when a take a print out I'm getting the website url on the top left side, How can we stop printing this?
Regards
When specifying a <link>
(such as to a CSS stylesheet) you can specify a media attribute so the CSS will only be used for print or screen. (or braille!) The CSS in this file can then re-style your site into columns as you see fit.
<link type="text/css" rel="stylesheet" href="print.css" />
You could specify two print CSS files like this, and - using JavaScript - prompt the user for which CSS file to use when they print, toggling the disabled
member of the <link>
:
var printCSS = document.getElementsByTagName("link")[n];
printCSS.disabled = true;
printCSS.disabled = false;
With mozilla, you can use the -moz-column-count
style:
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<title>Two columns</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
</head>
<body>
<div style='-moz-column-count:2'>
one<p>
two<p>
three<p>
four<p>
five<p>
six
</div>
</body>
</html>
It doesn't work with IE, however, and I don't think there's something equivalent for IE, either.
As for the printing of the URL, others have already pointed out that you have no control over it. The user can (and I usually do) in Firefox in the dialog File
-> Page Setup
-> Margins & Header/Footer
: set Header and footers to blank
.
You can add a style-sheet specific for printing and in theory that would allow you to print your content in 2 columns or 1, depending on user choice and how well your html is organized.
The address at the top of the print-out comes from the visitor's browser and I doubt you can turn it off at it is a setting that only the visitor has control over.
The URL appearing on the page is a browser setting and cannot be controlled by script.
Two print in two columns, make sure your HTML uses a print stylesheet and make sure your HTML can easily be reformatted in two columns using floats.
How to print a webpage in two columns or one column as per the user input/choice.
You could provide an alternative stylesheet using @media rule to provide a different layout that is only applied to print media … but I suspect this is better off left to the user's printer settings.
And when a take a print out I'm getting the website url on the top left side, How can we stop printing this?
This is a browser preference. Authors can't remove it.
精彩评论