I need to only use a piece of javascript when the print button is clicked, is there a way to do this?
EDIT: A browser print button, i was thinking something like this:
<script type="text/javascript" src="path" media="print"></script>
I need to only use a piece of javascript when the print button is clicked, is there a way to do this?
EDIT: A browser print button, i was thinking something like this:
<script type="text/javascript" src="path" media="print"></script>
There is only a partial support from browsers for that. Consider using special CSS stylesheet for print version of the page. For more details look at this question (there are links to several others): execute javascript when printing page
Some browsers (Firefox and IE) have events onBeforePrint onAfterPrint ...
https://developer.mozilla.org/en/Printing#Detecting_print_requests
Failing that use a "Press this to print" button and perform what you want from there ....
I think you mean this: JQuery:
$('#btnprint').click(function(){
//Your JS code goes here
});
Watch out with postbacks!
Im not sure wether u mean the browsers print button or just a custom one, the code above is for your own custom one..