Click to See Complete Forum and Search --> : print page


bjoerndalen
01-05-2003, 05:16 PM
Hi people...New to all this Javascript stuff and would like to kow if its possible to have a button on a page that is made up from frames. The button when pressed will print out only the frame that it occupies.If so any help with the code that'll make it work would be appreciated.

AdamBrill
01-05-2003, 05:24 PM
try window.print(); In a link it would look like this:

<a href="javascript:window.print();">test</a>

Good luck!

Charles
01-05-2003, 05:42 PM
If I'm not mistaken, that will only work in MSIE and only when JavaScript has not been disabled. To avoid a link to nowhere use:

<script type="text/javascript">
<!--
if (window.print) {
document.write('<a href="#">Print Me</a>');
document.links[document.links.length-1].onclick = function () {window.print(); return false}
}
// -->
</script>

bjoerndalen
01-05-2003, 05:46 PM
Thanks just tried the solution and it looks as though it'll work...Easy when you know how ...cheers:)