• Welcome to DNForum.com™ - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars
    If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the oldest global domain name community on the internet and continues to grow every day. There are over 45,000 domainers on DNForum doing everything from buying domains, selling domains, using our free in-house built tools, learning about domains and discussing domains. Take a minute and Register.

Wanted: Service Simple (?) JavaScript Question

Status
Not open for further replies.

BobBob is verified member.

Jedi Master
DNF Moderator
The Originals
Legacy Platinum Member
Joined
Apr 8, 2002
Messages
3,147
Reaction score
77
I want to print out a webpage via the window.print() command.

According to my documentation, window.print() acts exactly as if the user had clicked the "print" button. However, when the command is invoked, the print dialog box ALWAYS pops up.

When I click the little printer at the top of the IE browser, the page just goes to the printer. When I click "File->Print" I always get the print dialog box.

Is there a way to print the webpage without having the print dialog box come up and forcing the user to actually click "OK" or "Cancel" (i.e. simulate the little print icon at the top of the IE browser)?


-Bob
 
Unfortunately the answer is no.

Javascript doesn't provide a method for "print immediately" -- this would have to be pretty browser specific, as many browsers don't even have a "print immediately" functionality.

We looked into making an activex control to do it, but the client didn't want to pay for that. Post here if you find a free one!
 
I figured out that I cannot do that after I posted my message. UGH. It makes sense though. How would you like to go to a website and haveyour printer start printing a complete unedited version of "War and Peace"? :-)

My solution was to put everything I want to print on the browser screen and then issue the window.print() command after that. That eliminated the client from having to click the "Print" button in the print dialog box 800 times and only forces them to do it only once.

I also had the problem of making the output come out on nice pages and not having it all crammed together (i.e. the second page starts half way down the first page). Since HTML does not have a page-break tag, I was able to solve that problem by using a style. (style="page-break-after: always")

Coding - always an interesting job.

-Bob
 
Bob, now I understand why you have so much patience! :-)

WebCat
/\_/\
(0 0) php! Perl! Apache! javascript! Linux! CSS! .......AHRRGGGG!
>^<
\__/
 
WOW! Thanks nameslave.

FYI- it's an IE-only solution, but a solution nonetheless. Hopefully bad people don't get a hold of this, or we could be killing an exceptional number of trees.
 
Status
Not open for further replies.
Back
Top Bottom