PDA

View Full Version : open new window with css



tirso
02-26-2009, 01:55 AM
hi to all

I want to print selected div using javascript. On my current code it works fine in firefox. it will open new window and print with my desired style using css but unfortunately in IE it will open new window but the css doesn't applied.

thanks in advance

tirso


here is my code


<div id="printarea"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<link href="css/css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="formdiv">
<table width="70%" border="1" cellspacing="0" cellpadding="0" align="center" style="margin-top: 20px;">
<tr>
<td align="center" width="500px">
<div id="main">
<img src="images/card_bg9.jpg" width="499" />
<div class="contentname">Tirso Garcia JR</DIV>
<div class="contentposition">Project Manager</div>
<div class="emailtel">
<div align="right" class="text7"><span class="text8">Email Address :</span> tirso@localhost.com<br />
<span class="text8">Mobile Number :</span> 11111111 <br /><span class="text8">Company School :</span> Thinkpadd </div>
</div>
<div class="country">Caloocan City</div>
</div>
</td>
<td align="center" width="500px">
<div id="main">
<img src="images/card_bg9.jpg" width="499" />
<div class="contentname">Tirso Garcia JR</DIV>
<div class="contentposition">Project Manager</div>
<div class="emailtel">
<div align="right" class="text7"><span class="text8">Email Address :</span> tirso@localhost.com<br />
<span class="text8">Mobile Number :</span> 11111111 <br /><span class="text8">Company School :</span> Thinkpadd </div>
</div>
<div class="country">Caloocan City</div>
</div>
</td>
</tr>
</table>
<div align="right" style="width: 80%; margin: auto; margin-top: 5px; margin-bottom: 10px" id="printbutton"><input name="print" type="button" value=" Print " class="highlight"/></div>
</div>
</body>
</html>
</div>


javascript


function printIt(target)
{
//alert (target);
winId=window.open('','printwin','width=1000,height=800');
winId.document.write(target);
winId.document.close();
winId.focus();
if (window.print) winId.print();
}