Thursday, September 8, 2011

Print particular HTML tag alone

<html>
<title>Hai</title>
<head>
<script language="javascript">
    function printme() {
        var content = document.getElementById("div3");
        var pri = document.getElementById("ifmcontentstoprint").contentWindow;
        pri.document.open();
        pri.document.write(content.innerHTML);
        pri.document.close();
        pri.focus();
        pri.print();
    }
</script>
</head>
<body>
<div id="div1">Welcome to Intel Malaysia</div>
<div id="div2">Good Morning</div>
<div id="div3">detached, divided, or separated by cutting
2. (Life Sciences & Allied Applications / Botany) Botany incised or divided cut leaves
3. made, shaped, or fashioned by cutting
4. reduced or diminished by or as if by cutting cut prices
5. (Life Sciences & Allied Applications / Veterinary Science) gelded or castrated
6. weakened or diluted
7. Brit a slang word for drunk
8. hurt; resentful
cut and dried Informal settled or arranged in advance
</div>
<iframe id="ifmcontentstoprint" style="height: 0px; width: 0px; position: absolute"></iframe>
<form name="frmPrintForm">
<input type="button" name="btnPrint" onclick="javascript:printme();" value="Click Me to Print" />
</form>
</body>
</html>

No comments:

Post a Comment