SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Apr 30, 2005, 15:30 #1
- Join Date
- Apr 2005
- Location
- Bangalore, India
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Print Particular section on page!
i have two layers which i show and hide as per the users requirement...how do i give a link to print the contents of the layer only???
CavemanDon't ask what your Country can do for you,
Ask what you can do for your Country.
-
Apr 30, 2005, 22:41 #2
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This will open the layer that you want to print, insert that layer into a new window print and then close.
Code:<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="javascript" type="text/javascript"> function printlayer(layer) { var generator=window.open('','name',''); var layertext = document.getElementById(layer); generator.document.write(layertext.innerHTML.replace("Print me","")); generator.document.close(); generator.print(); generator.close(); } </script> </head> <body> <div id="Layer1" style="position:absolute; left:52px; top:37px; width:174px; height:118px; z-index:1">This is text one<br> <br> <a href=javascript:printlayer('Layer1')>Print me </a></div> <div id="Layer2" style="position:absolute; left:239px; top:37px; width:174px; height:118px; z-index:1">This is text two<br> <br> <a href=javascript:printlayer('Layer2')>Print me</a> </div> </body> </html>
-
May 1, 2005, 01:44 #3
- Join Date
- Apr 2005
- Location
- Bangalore, India
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Gee...thanks a lot..this is of great help...
Don't ask what your Country can do for you,
Ask what you can do for your Country.
-
May 1, 2005, 07:58 #4
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I thought this would work, but it would show the print dialog box, which I don't know if thats what you want.
But apart from that, thank you
-
May 1, 2005, 16:30 #5
- Join Date
- Sep 2002
- Location
- Bournemouth, South UK
- Posts
- 1,551
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
If you are going to use javascript the document.write, when done after the page has loaded, will create a new page.
so you can use thisCode:<a href="javascript:document.write(document.getElementById('div_2_show').innerHTML)">
LiveScript: Putting the "Live" Back into JavaScript
if live output_as_javascript else output_as_html end if
Bookmarks