Results 1 to 8 of 8

Thread: problem with the printing of alternative page

  1. #1
    Join Date
    Nov 2007
    Posts
    69
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Default problem with the printing of alternative page

    hi forum
    i m trying to print two different pages as soon as the form is saved.

    i tried to use this command
    <A HREF="javascript:window.print()">Print 1st Page</A>
    <A HREF="javascript:window.print()">Print 2nd Page</A>

    but i was unable to use the link command to force the printer to print the two other pages

    print 1st page should print cust1.htm
    and print 2nd page should print cust2.htm

    any ideas how to go ahead for the same?
    smile always
    anand

  2. #2
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by motormichael12 View Post
    How does that help? From looking at that thread, there is no solution that works for printing more than one document. Not only that, the solution given there (which was for printing an alternate document) only works in IE - as stated in the thread!

    In this thread:

    http://www.dynamicdrive.com/forums/s...ad.php?t=31688

    particularly after I got involved with it (post 21), we figure out a means for printing iframed content across browsers. That might be able to be used for what meenakshi wants to do. But as I recall, the iframes cannot be visibility:hidden; or display:none;, but they could possibly be positioned absolutely out of view of the user and/or have small dimensions.

    If you have both pages to be printed in separate windows. Each window could be printed. However it is done though, there might be problems with spooling multiple print jobs, particularly in IE, as its print command routines do sometimes cancel other javascript, I'm not sure if that would apply here or not.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. The Following User Says Thank You to jscheuer1 For This Useful Post:

    meenakshi (08-23-2008)

  5. #4
    Join Date
    Nov 2007
    Posts
    69
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Default

    hi
    thanks for the reply
    first of all i m only using ie for i m working on a standalone machine.
    secondly i will be using two different buttons to print two different pages.
    so that means that first link willl point different html page and second print link point different html page
    i hope this clears my issue
    pls help
    smile always
    anand

  6. #5
    Join Date
    Nov 2007
    Posts
    69
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Default

    hi for convience sake i am attaching the html file with the code
    maybe i m not able to explain things in details
    this way it might be possible
    i have written a short note just next to the form i html file
    pls see it and advice how i should go ahead
    smile always
    anand

  7. #6
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    1. In the HTML page you've provided contains two body elements though the browser will never show any error, you need to avoid such issues.

    2. You will not be able to print the content of two different pages using "window.print()" in another page. "window.print()" is supposed to print the content of the page in which you've furnished that code. For printing some other pages from another page you have to use some sort of frames or AJAX methods.

    Below you can find a iframe based method using which you can print two different files from a third file:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    	<head>
    		<title>Untitled Document</title>
    		<style type="text/css">
    
    		</style>
    		<script type="text/javascript">
    		function printPg(ifrmname){
    			if(top.frames[ifrmname]){
    				top.frames[ifrmname].focus();
    				top.frames[ifrmname].print();
    			}
    		}
    		
    		</script>
    	</head>
    	<body>
    		<h1>This is the main file from which I want to print two other files</h1>
    		<div>
    			<iframe name="one" width="0" height="0" frameborder="0" src="1.htm"></iframe>
    			<iframe name="two" width="0" height="0" frameborder="0" src="2.htm"></iframe>
    		</div>
    		<div>
    			<a href="#" onclick="printPg('one');return false;">Print One</a>
    			<a href="#" onclick="printPg('two');return false;">Print Two</a>
    		</div>
    	</body>
    </html>
    (a) In the first iframe I've mentioned the first page which needs to be printed. Like that in the second iframe I've mentioned the second page that needs to be printed.

    (b) The width and height of both iframes kept as "0" as we don't want to display the first and second page content in my third file( the file from which am going to print).

    (c) From the anchor element's onclick event I've called a JS function and passed the name of the iframes into the function.

    Now you should be able to view the printer dialog box. I've checked it in IE 7 and FF 3.0.1 in both it works correctly.

    Please find all the files I've used in this case as attachment. Unzip them, keep them together and browse "main.htm" and try to click the links available in the page.

    Hope this helps.

  8. The Following User Says Thank You to codeexploiter For This Useful Post:

    meenakshi (09-02-2008)

  9. #7
    Join Date
    Nov 2007
    Posts
    69
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Default

    hi codex
    hi forum
    wow this is working to perfection and it is really nice to learn this new way to print without opening the page itself
    good
    thanks once again
    smile always
    anand

  10. #8
    Join Date
    Nov 2007
    Posts
    69
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Default

    hi codex
    i am having a problem with the printing
    i m using frames to call this page on the right where i enter all the data and then save it and it goes to print using the iframe .here the problem comes.it does not pass the page to printer as it should do and the most funny part is that when i try to do the same thing without frames it does things normally that is print the page as it should do.
    pls advice how i should do this for proper functionality
    i m attaching the files for your reference.
    please click on send for 1st fitting to test the issue
    thanks
    anand
    smile always
    Last edited by meenakshi; 09-07-2008 at 04:43 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •