Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2005, 04:55 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default Print only Table

I have a web page which have few contets and pictures and have a print button which use print()function to print that page. So now it prints the whole page but I want to print only the contents of the page. Any one who can guide me that how can I print only the contents of the page. Second problem is that a part of the page is comming dynamically from one website. So how can I stop that part for not printing ?

Any help will be appriciated
Thanks in advance





(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is how you got it
__________________
(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is  how you got it
 
Old October 3rd, 2005, 05:02 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Take a look at this article: http://imar.spaanjaars.com/QuickDocId.aspx?QUICKDOC=240

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 4th, 2005, 03:59 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

Hi Amar thanks for the comments but the problem is that I donot access to the other page which is include in that page so how can I apply that css on that page

(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is how you got it
 
Old October 4th, 2005, 12:24 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I don't think you can do that (directly). The other page (I assume it's an iframe??) has its own style sheet information applied that cannot be changed / influenced directly.

Do you have script access to the page's content from within your page? That is, can you get its HTML through script?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 17th, 2005, 08:07 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

I had a similar problem about a month ago, try loading what you want to print into an iframe <iframe> and using JavaScript to print only that iframe:
Code:
// Function to print out a page that has not been 
// loaded onto the screen
function printURL (url) {
  if (window.print && window.frames && window.frames.printerIframe) {
    var html = '';
    html += '<html>';
    html += 
'<body onload="parent.printFrame(window.frames.urlToPrint);">';
    html += '<iframe name="urlToPrint" src="' + url + '"><\/iframe>';
    html += '<\/body><\/html>';
    var ifd = window.frames.printerIframe.document;
    ifd.open();
    ifd.write(html);
    ifd.close();
  }
  else {
    if (confirm('To print a page with this browser ' +

'we need to open a window with the page. Do you want to continue?'))
    {
      var win = window.open('', 'printerWindow', 
'width=600,height=300,resizable,scrollbars,toolbar,menubar');
      var html = '';
      html += '<html>';
      html += 
'<frameset rows="100%, *" ' +
 'onload="opener.printFrame(window.urlToPrint);">';
      html += '<frame name="urlToPrint" src="' + url + '" \/>';
      html += '<frame src="about:blank" \/>';
      html += '<\/frameset><\/html>';
      win.document.open();
      win.document.write(html);
      win.document.close();
    }
  }
}

function printFrame (frame) {
  if (frame.print) {
    frame.focus();
    frame.print();
  }
}

www.crmpicco.co.uk




Similar Threads
Thread Thread Starter Forum Replies Last Post
Print Table-Fields on three different pages ketannsharma Access 1 February 20th, 2007 09:08 AM
Print and print preview file on the website withou appleLover General .NET 0 February 19th, 2005 02:24 AM
Print the layout of a table in Access rylemer Access 2 August 31st, 2004 12:55 PM
Print table headers rajanikrishna HTML Code Clinic 6 August 28th, 2004 02:23 AM
How Do I Print Table Cell Colours? Lucy HTML Code Clinic 4 December 3rd, 2003 12:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.