473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Print Preview using JavaScript onClick?

The client insists on having a link or button that the user can click
to view the printable version in the browser. I already have the css
done for the print version, so thats not a problem. I don't want to
create duplicate pages if I can help it (I anticipate many updates as
the months go by, and I don't want to have to do double the work).

I know I have seen this functionality before, but I can't seem to find
it now. Is there existing script to open the print preview pane with an
onClick?

Any help is greatly appreciated.

Kebmo

Oct 27 '05 #1
6 21413
VK

Kebmo wrote:
The client insists on having a link or button that the user can click
to view the printable version in the browser. I already have the css
done for the print version, so thats not a problem. I don't want to
create duplicate pages if I can help it (I anticipate many updates as
the months go by, and I don't want to have to do double the work).

I know I have seen this functionality before, but I can't seem to find
it now. Is there existing script to open the print preview pane with an
onClick?

Any help is greatly appreciated.

Kebmo


In the document <head> : (no JavaScript needed)

<link rel="stylesheet"
type="text/css"
media="all"
href="stylesCommon.css">
<link rel="stylesheet"
type="text/css"
media="screen"
href="stylesBrowser.css">
<link rel="stylesheet"
type="text/css"
media="print"
href="stylesPrint.css">

Oct 27 '05 #2
Thanks. I have this sort of setup already. When the user prints the
page, it uses the print-only styledsheet I made for that purpose.

What I need is to be able to click a link or button and open the Print
Preview pane just as if I had gone to file-->print preview.

Is this even possible?

Oct 27 '05 #3
Kebmo wrote on 27 okt 2005 in comp.lang.javascript:
Thanks. I have this sort of setup already. When the user prints the
page, it uses the print-only styledsheet I made for that purpose.

What I need is to be able to click a link or button and open the Print
Preview pane just as if I had gone to file-->print preview.

Is this even possible?
Using serverside jscript unser ASP:

<%@ Language=JScript %>
<link rel="stylesheet"
type="text/css"
media="all"
href="stylesCommon.css">

<link rel="stylesheet"
type="text/css"
media="screen"
<% ' ASP Jscript
if(request.querystring('print')=='yes'){
%>
href="stylesBrowser.css"
<%
}else{
%>
href="stylesPrint.css"
<%
};
%>


<link rel="stylesheet"
type="text/css"
media="print"
href="stylesPrint.css">

.......

<a href='?print=yes'>Print preview</a>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 27 '05 #4
rf
Kebmo wrote:
The client insists on having a link or button that the user can click
to view the printable version in the browser.


Teach your client how to use File>Print Preview. Then she will stop wanting
that.
--
Cheers
Richard.
Oct 27 '05 #5
rf wrote on 27 okt 2005 in comp.lang.javascript:
Kebmo wrote:
The client insists on having a link or button that the user can click
to view the printable version in the browser.


Teach your client how to use File>Print Preview. Then she will stop
wanting that.


Or let them use Fineprint.

<http://www.fineprint.com/>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 27 '05 #6
Another option (the one that I use) is MeadCo's ScriptX ActiveX object.
They also have a way to make it (and pretty much any other ActiveX object)
work with other browsers.
Check out http://www.meadroid.com/scriptx/about.asp
Dave

"Kebmo" <im***********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
The client insists on having a link or button that the user can click
to view the printable version in the browser. I already have the css
done for the print version, so thats not a problem. I don't want to
create duplicate pages if I can help it (I anticipate many updates as
the months go by, and I don't want to have to do double the work).

I know I have seen this functionality before, but I can't seem to find
it now. Is there existing script to open the print preview pane with an
onClick?

Any help is greatly appreciated.

Kebmo

Nov 3 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing...
4
by: miarte | last post by:
I have a form to allow the user upload images. The user browse for an image in their computer and click open, th image to be upload is preview on the img tag. The script works fine with IE, but...
2
by: AP No spam | last post by:
Hi I need help to Print Pdf File directly without preview from client side To solve problem I used This C# code Response.Buffer = true;
2
by: Gernot Frisch | last post by:
Hi, I'd like to have an textarea, where I type HTML code. While typing, I'd like to see the result at the bottom of the page (in a DIV?) to be show. Can you help? -- -Gernot int main(int...
6
by: CSharpguy | last post by:
In my gridview I have 2 -3 template fields which are hyperlinks. I allow the user to print this grid. When the grid prints it also prints the links, how can I take the user to a print preview page...
9
by: igotyourdotnet | last post by:
I need to create a print preview page BUT my page I need to print has a grid and in the grid I have 2 or 3 columns that have links I want to hide the columns with the links on my print preview page...
7
by: Fareast Adam | last post by:
I try to hide the print preview button that inside <div id="button"> when previewing the page. But the the problem happened the button is always hidden after i closing the preview page. Anyone have...
0
by: agarwalsunitadhn | last post by:
hi.. How will i use print and print preview option. I have to print only a part of a page. for that i declare in a div and give that a id and then using java function to print that portion but my...
5
by: maminx | last post by:
hello all, i want to call window print preview (in browser, File - Print Preview) by javascript, this is the code function printpreview() { var OLECMDID = 7; /* OLECMDID values: * 6...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.