Last active
November 11, 2025 00:55
-
-
Save mothdotmonster/9aa9da19f8cb7eb7ca053dd5f9ae618a to your computer and use it in GitHub Desktop.
makes the print() function accept arguments as it should
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
| function print(object) { | |
| let frame = document.createElement("iframe") | |
| document.body.appendChild(frame) | |
| frame.style.display = "none" | |
| frame.srcdoc = new Option(JSON.stringify(object, null, 1)).innerHTML | |
| frame.onload = () => {frame.contentWindow.print()} | |
| } |
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
| function print(o){let f=document.createElement("iframe");document.body.appendChild(f);f.style.display="none";f.srcdoc=new Option(JSON.stringify(o,null,1)).innerHTML;f.onload=()=>{f.contentWindow.print()}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment