Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Sponsored Links

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
 
LinkBack Thread Tools Display Modes
  #1  
Old June 23rd, 2008, 01:02 PM
Barn Frequenter
 
Join Date: Mar 2008
Posts: 197
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  
Old June 23rd, 2008, 01:12 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 863
Thanks: 20
Thanked 78 Times in 75 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net 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
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #3  
Old June 23rd, 2008, 01:19 PM
Barn Frequenter
 
Join Date: Mar 2008
Posts: 197
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  
Old June 23rd, 2008, 01:22 PM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 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  
Old June 25th, 2008, 12:24 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 863
Thanks: 20
Thanked 78 Times in 75 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net 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  
Old June 25th, 2008, 01:36 PM
richyrich's Avatar
Super Moderator
 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 417
Thanks: 26
Thanked 34 Times in 34 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
JavaScript Classic ASP 
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


All times are GMT -4. The time now is 08:04 PM.



Content Relevant URLs by vBSEO 3.2.0