Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created November 22, 2012 01:50
Show Gist options
  • Save claudiosanches/4128987 to your computer and use it in GitHub Desktop.
Save claudiosanches/4128987 to your computer and use it in GitHub Desktop.
jQuery print page
<!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