Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-18-2002, 03:57 AM   PM User | #1
ledzep
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ledzep is an unknown quantity at this point
Printing

I would like to be able to print a selection of an HTML page rather than the whole page. is there a way to achieve this?
Thanks for any help
ledzep is offline   Reply With Quote
Old 06-18-2002, 08:55 AM   PM User | #2
mordred
Senior Coder


 
Join Date: Jun 2002
Location: frankfurt, german banana republic
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
mordred is an unknown quantity at this point
You would have to grab the desired elements and by some DHTML functionality and pass them to a new blank document, which you have opened in a new window or in a frame. Perhaps it's even possible to do this in a hidden <iframe>.
Then you only have call the window.print() method of that new document.
mordred is offline   Reply With Quote
Old 06-18-2002, 01:31 PM   PM User | #3
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
<style type="text/css" media="screen">

img { display:inline; }

</style>
<style type="text/css" media="print">

img { display:none; }

</style>


This simple example will declare that all IMG tags do not print. By extending this method, you can specify any area of the page to print or not print
brothercake is offline   Reply With Quote
Old 06-18-2002, 07:54 PM   PM User | #4
ledzep
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ledzep is an unknown quantity at this point
Hi

Thanks guys for the help. I will look into these options
ledzep is offline   Reply With Quote
Old 06-19-2002, 02:48 PM   PM User | #5
jalarie
Regular Coder

 
Join Date: Jun 2002
Location: Flint, Michigan, USA
Posts: 593
Thanks: 1
Thanked 19 Times in 19 Posts
jalarie is an unknown quantity at this point
Sel='';
function PrintSelected() {
if (window.frames.length == 0){
Sel=document.getSelection();
} else {
for (iy=0;iy<window.frames.length;iy++){
Fm=window.frames[iy];
Sel=Sel+Fm.document.getSelection();
}
}
var Opts='width=100,height=100'; PS_Pop=window.open('','PrintSel',Opts);
PS_Pop.document.write(Sel);
PS_Pop.document.close();
this.window.focus();
PS_Time=setTimeout("PrintSelected2()",1000);
}
function PrintSelected2() {
PS_Pop.window.print();
PS_Time=setTimeout("PrintSelected3()",5000);
}
function PrintSelected3() {
PS_Pop.window.close();
}
jalarie is offline   Reply With Quote
Old 06-19-2002, 06:55 PM   PM User | #6
ledzep
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ledzep is an unknown quantity at this point
Thanks Jalarie for your solution which I will try out
ledzep is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:33 PM.


Advertisement
Log in to turn off these ads.