问题
I'm working with Dreamweaver, coded in php.
On one of my pages, I'm trying to add 2 different print
buttons
, each one printing a differrent portion of the webpage. For example, one print button is printing the first paragraph and the other print
button is printing the second paragraph.
I did the print CSS for both buttons and I linked each to its respective print CSS, but the second print CSS overrules the first one, and so I end up having two print buttons with the same CSS...
What do I need to do?
回答1:
You could dynamically change the print CSS based upon which button is clicked with something like this:
Add an id to your stylesheet reference:
<link rel="stylesheet" href="print1.css" id="printCss" media="print">
Add an on click event to your button:
<input type="button" onclick="swapCss();"/>
Dynamically swap the css file:
function swapCss() {
document.getElementById('printCss').href = 'print2.css';
}
来源:https://stackoverflow.com/questions/18496945/two-print-buttons-with-different-css-on-the-same-page-possible