JavaScript Print HTML Content Div With Style



index.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Javascript Print Color Content</title>
<script type="text/javascript">
function printDocs(){
var content = document.getElementById('main_wrap').innerHTML;
var win = window.open();
win.document.write(content);
win.print();    // JS print function
win.close();    //close window after print.
}
</script>
</head>
<body>
<a href="javascript:void(0)" onClick="printDocs();return fasle;">Pring Docs</a><br>
<div id="main_wrap">
<style type="text/css">
*{
font-family: arial;
}
.wrapper{
width: 950px;
margin: 0 auto;
height: auto;;
border: 1px solid #000;
}
.blue{
color:blue;
}
p{
color: red;
}

</style>
<div class="wrapper">
<h4 class="blue">NAME: Ram Pukar</h4>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</div>
</body>

</html>
--------------------------------------------------
Demo:

Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment