Created
April 7, 2011 11:48
-
-
Save zgordon/907626 to your computer and use it in GitHub Desktop.
Pure JavaScript model of how to build and add to screen a working print button
This file contains 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
window.onload = function() | |
{ | |
if(!document.getElementsByTagName) return false; | |
var print = document.createElement("a"); | |
print.href = "#"; print.id = "printlink"; | |
var print_icon = document.createElement("img"); | |
print_icon.src = ("printer.png"); | |
var print_link_node = document.createTextNode("print"); | |
print.appendChild(print_icon); | |
var notice = document.getElementById("notice"); | |
notice.appendChild(print); | |
print_link = document.getElementById("printlink"); | |
print_link.onclick = function() { window.print(); } | |
function insertAfter(referenceNode, newNode){ referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling ); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment