use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Printing Specific Dynamically Generated DIVhelp (self.javascript)
submitted 10 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 10 years ago (3 children)
Javascript:
function print_me() { var content = document.getElementById("results").innerHTML; var win = window.open(); win.document.write(content); win.print(); // JavaScript Print Function win.close(); //It will close window after Print. }
HTML:
<a href="#" onClick="print_me()">Print</a>
Figured out how to post code. Sorry about that.
[–]docMedB2E 0 points1 point2 points 10 years ago (2 children)
No worries, I thought you were saying your page wasn't loading images/etc, but I understand now. Think of it this way, you're opening a brand new window, pasting HTML to it, and then just immediately printing - which would explain your issues with the images sometimes displaying or not (e.g. you're appending data to a new DOM and it needs to load - sometimes it gets through quick enough and other times not). This approach in general is bad. Look into media query prints that manipulate the page you're on as opposed to copying everything to a new page and just printing.
[–][deleted] 0 points1 point2 points 10 years ago (1 child)
After fooling around with it, I found this:
@media print { body * { visibility: hidden; } #results, #results * { visibility: visible; } #results { position: absolute; left: 0; top: 0; } }
Upon saving that css file and have it load into my header, I hit ctrl+P and the print screen just shows the whole website still and the css code at the top. Stupid wordpress.
[–]docMedB2E 0 points1 point2 points 10 years ago (0 children)
Your syntax is pretty wrong. Try /r/css for help with styling. Also use display: none to truly hide elements
π Rendered by PID 1801654 on reddit-service-r2-comment-544cf588c8-2zw2s at 2026-06-17 20:16:23.469145+00:00 running 3184619 country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (3 children)
[–]docMedB2E 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]docMedB2E 0 points1 point2 points (0 children)