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???
Caveman
Printable View
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???
Caveman
This will open the layer that you want to print, insert that layer into a new window print and then close.
Let me know if this is what you want?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>
Gee...thanks a lot..this is of great help... :)
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
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 thisyou can even use this with target="_new"Code:<a href="javascript:document.write(document.getElementById('div_2_show').innerHTML)">