Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Thursday, May 26, 2011

Check if JS function exists

if(typeof yourFunctionName == 'function') {
yourFunctionName();
}

Thursday, December 30, 2010

javascript print function

function printbyid(sId) {
var oPrn = document.getElementById(sId);
var oWin = window.open('', "quickprint");
oWin.document.writeln(oPrn.innerHTML);
oWin.document.close();
oWin.focus();
oWin.print();
oWin.close();
}

< div id="sprint" >
....
< / div >

< input type="button" value="Printeaza Raport" onclick="printbyid('sprint');" / >

Thursday, December 9, 2010

Print the content of a DIV using javascript

<head>
<style type="text/css">

@media print
{
#non-printable { display: none; }
#printable { display: block; }
}
</style>
</head>
<body>
<div id="printable">
The content of the page that needs to be printed.
</div>

<div id="non-printable">
<a href="javascript:void(0);" onclick="javascript:window.print();">Print Content</a>
</div>
</body>