DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Discuss "print problem" in the JavaScript Programming forum.

JavaScript Programming - Javascript is a cross-browser client-side scripting language. Discuss Javascript and AJAX related scripts here.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old June 23rd, 2008, 01:02 PM
Contributing Member

 
Join Date: Mar 2008
Posts: 188
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default print problem

Hi,


I have this code on the page which displays a image.

<a href="print.asp?id=<%=ID%>"><img src="/image/imglink.gif" border="0" /></a>

When a person clicks on the image it opens up print.asp

What i want to do is when a person clicks on the image i want to print the page print.asp

i tried window.print but its not working

can someone tell me what i am doing wrong

todd
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old June 23rd, 2008, 01:12 PM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 543
Thanks: 14
Thanked 41 Times in 40 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

On print.asp, just call the window.print in the body onload event:

Code:
<body onload="javascript:window.print();">
__________________
jmurrayhead
Did I help you out? Make me popular by clicking the icon!

If you found a post helpful, please click the button in the lower right-hand corner of the post.

Powered by ASP.Net
Reply With Quote
  #3 (permalink)  
Old June 23rd, 2008, 01:19 PM
Contributing Member

 
Join Date: Mar 2008
Posts: 188
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default

I tried it buddy it works

But my problem is I dont want to display print.asp to the user

I just want it to be printed is there a way I can make it happen

also when the page is printed

It shows the URL at the bottom of the page

Can i hide that url

todd
Reply With Quote
  #4 (permalink)  
Old June 23rd, 2008, 01:22 PM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 150
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Printing support in browser basically sux. The URL footer is controled by the Print Setup function of the user's Browser, so I know of no way to suppress this.

I also don't know of a way to keep the page from displaying.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
  #5 (permalink)  
Old June 25th, 2008, 12:24 PM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 543
Thanks: 14
Thanked 41 Times in 40 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

I agree with Wolffy and giving a script that kind of control over a browser would be a security issue.
Reply With Quote
  #6 (permalink)  
Old June 25th, 2008, 01:36 PM
richyrich's Avatar
Moderator


 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 332
Thanks: 23
Thanked 27 Times in 27 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

I use this activex control. Means users have to install it onto their machine, but it allows you to control the margins, header, footer etc.

Linky

I also don't know of a way to print the page without displaying it. It's just printing whatever is displayed in the browser so if there's nothing there it won't print anything.

You can open the page and call a JS function onload that prints the page, either using this activex or as shown above and then use window.close to immediately close the window.

Hope that helps.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Print out data on a letterhead format Shem .Net Development 3 May 22nd, 2008 09:15 AM


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 12:23 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46