JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 15th, 2001, 08:24 AM
bakedbean bakedbean is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Location: Boston
Posts: 261 bakedbean User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 37 m 16 sec
Reputation Power: 12
Send a message via AIM to bakedbean
printing with javascript

can someone point me in the direction of some decent documentation of how to print a file with javascript from a browser?

Any help is appreciated.

Reply With Quote
  #2  
Old November 15th, 2001, 10:32 AM
binky's Avatar
binky binky is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: New Zealand
Posts: 1,774 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 58 m 15 sec
Reputation Power: 23
No one replying? Possibly because there's no real documentation

Start by trying:

window.print()

If you're printing a different frame then IE needs to set the focus first:

var isIE = null
if (navigator.appVersion.indexOf("MSIE") != -1) {
isIE = true
}
if (isIE) {
parent.frame.focus()
this.print()
} else {
parent.frame.print()
}


Don't know about any lesser browsers such as NS4 though!

Oh yeah, and before adios berates me once again for saying window.something when the window. isn't needed, I just do things that way okay?!

So you can use print()

instead of window.print()

Last edited by binky : November 15th, 2001 at 10:34 AM.

Reply With Quote
  #3  
Old November 15th, 2001, 10:37 AM
binky's Avatar
binky binky is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: New Zealand
Posts: 1,774 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 58 m 15 sec
Reputation Power: 23
Oh, and added to all that. If you're printing anything other than the web page it doesn't work. You can't print any old file from the users filesystem because that would be dangerous. If it's something that is pretty secure and being used by people you know then you could get them to download an HTA version or a Java method of doing it. But really it's not worth the effort.

May be that's not what you're after but I'm just suggestin'!

Reply With Quote
  #4  
Old November 15th, 2001, 10:43 AM
bakedbean bakedbean is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Location: Boston
Posts: 261 bakedbean User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 37 m 16 sec
Reputation Power: 12
Send a message via AIM to bakedbean
actually that's exactly what I was looking for... you see I'm trying to escape having to print from the browser window becuase the browsers impose all sorts of whacky formatting. I need to be able to print data retrieved from a database onto a page in very specific locations. So I am trying to figure out how to initiate a print command to print a generated text file that would reside on the server.

Reply With Quote
  #5  
Old November 16th, 2001, 06:18 AM
binky's Avatar
binky binky is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: New Zealand
Posts: 1,774 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 58 m 15 sec
Reputation Power: 23
What you could do is format it all nicely (but no need if it's just a text file). Then have PHP or ASP load the text file into a very simplistic web page and print that using the print option of the browser.

Banks such as Smile (I've noticed) give the option to ask for print formatting on a page when printing. This opens a new window with a neat version.

It's possible to do a media option in CSS that allows for different CSS properties for screen and print display. So you can hide things when a page is printed out without having to do any changes on screen. (This is something I have been planning on getting around to, eventually).

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > printing with javascript

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap