navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Free FrontPage Templates

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

A Hyperlink that Prints

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> A Hyperlink that Prints
Page: [1]
 
Valaire

 

Posts: 99
From: New York
Status: offline

 
A Hyperlink that Prints - 8/23/2002 12:50:06   
Hi, I had posted this in another forum, but it might be relevant to this one, so I' m reposting it...

Basically what I want to do is have a link that takes you to another page and automatically prints that page, at the same time.

The only thing slightly complicated is that the URL is a page variable derived from an asp script. I was told to use the LINK element in the HEAD, but I am having no luck... this is the code I have now... the LINK in the head, the ASP script that determines the URL, and the hyperlink:

<link rel=alternate media=print href=" ../Database/Print/externalprint.asp" >
<%
Dim PrintID, Form

Form = " External Power" 
PrintID = Request.Form(" ID" )

If PrintID <> VBNULLString Then
  URL = " ../Database/Print/externalprint.asp?ID=" 
  URL = URL & PrintID
Else
  Session(" DB" ) = Form
  URL = " ../Database/Print/printerror.asp" 
End If  
%>
  <a href=" <%=URL%>" ><img border=" 0"  src=" ../Images/Sidebar/new(w).jpg" ></a>


I just cut out those 3 parts, they' re not actually in order like that. The link element is in the head section, and the rest is in the body.

< Message edited by valaire -- 8/22/2002 12:51:09 PM >
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: A Hyperlink that Prints - 8/23/2002 13:00:12   
Valarie,

On the page that you want to print, place the following code at the very top of the page:

<SCRIPT TYPE=" text/javascript" >
<!--
function printme()
{
window.print()
}
//-->
</SCRIPT>


Now locate the line in your code (on the page you want to print) that says:

<body>

Change it to say:

<body onload=" printme()" >

This will print the page automatically when the page loads in.

Good luck

(in reply to Valaire)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: A Hyperlink that Prints - 8/23/2002 13:04:55   
I' m not sure if the print in the head is going to give you what you want...

the way it looks, it will print the page as it was written... in code... not the way it would appear on the screen. Since it' s a " linked print" the page isn' t actually being " renered" by a browser, so it' s going to print in its raw form...

That' s just in theory...

Have you tried looking for a Javascript or something that prints the page? Set it up to do an " on-load" print or something? Then you can set a variable in the link like Print=" yes"

On the page if print = " yes" then you run the print-page script, otherwise just load the page...

I' ll dig around and see if I can find anything...

Good luck!

_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to Valaire)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: A Hyperlink that Prints - 8/23/2002 13:13:09   
Bobby,

Sorry, I overwrote you. We must have answered Valarie' s question at the same time. Sorry about that!! :)


Valarie,
The method I gave you works. I tried it. Send the link to this page as you are doing now. The code I gave you should be put INSIDE the actual page you want to print. When you test it, the page will display. After it displays the print dialog box will appear. :)

LLL

(in reply to Valaire)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: A Hyperlink that Prints - 8/23/2002 13:19:40   
LLL -

That' s what I was going for! I just dug around and found some similar JS and was about to post it here!

The only thing I might add is an if... then to the onload print...

Can you place the function into a variable check like:

<%
If PrintThis=" yes" then
%>
script to run the printme() function
<%
else
end if
%>

By using this you can place the PrintThis=" yes" into the print + link and not include it in standard links to the page... this will enable you to link to the page without printing it every time..?

I' m not a JS hound, so I' m not positive how to accomplish the if... then statement for the script to run..?

Also, should that be placed at the beginning of the page? Or towards the end? I can' t remember if the onload print will come before or after the rest of the ASP is processed..?

_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to Valaire)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: A Hyperlink that Prints - 8/23/2002 13:40:18   
Bobby,

I tested it at the beginning of the page. I guess it really doesn' t matter where you put it as long as it' s there.

Yes, an " If... then..." would allow Valarie the option of choosing whether to print the page or not. Good point!!!

The code I provided I prefer to connect to a button myself.

_____________________________


(in reply to Valaire)
Valaire

 

Posts: 99
From: New York
Status: offline

 
RE: A Hyperlink that Prints - 8/23/2002 13:47:59   
Thanks fellas, trying them out now. :)


-- Works like a charm.



< Message edited by valaire -- 8/22/2002 1:52:00 PM >

(in reply to Valaire)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: A Hyperlink that Prints - 8/23/2002 14:02:49   
:) Cheers!!! :)

_____________________________


(in reply to Valaire)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: A Hyperlink that Prints - 8/23/2002 14:37:35   
quote:

it really doesn' t matter where you put it as long as it' s there.


Thanks, good to know...


:)

_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to Valaire)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: A Hyperlink that Prints - 8/24/2002 11:06:22   
Ahhhhhhhhhhhhh so true!!!

_____________________________


(in reply to Valaire)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> A Hyperlink that Prints
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts