Two print buttons with different css on the same page… Possible?

谁都会走 提交于 2019-12-11 12:19:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!