Created
November 22, 2012 01:50
-
-
Save claudiosanches/4128987 to your computer and use it in GitHub Desktop.
jQuery print page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html dir="ltr" lang="pt-BR"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Print</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
$('.print-this').on('click', function(e) { | |
// Prevents the click event of default, which would take the user to the top of the site. | |
e.preventDefault(); | |
// The magic happens here xD. | |
window.print(); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<a href="#" class="print-this" title="imprimir">Imprimir</a> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment