Home  |  About  | Last |  Submit  |  Contact
AllQuests.com



Previous Question:  JS page done loading  Client Side (HTML, CSS, JavaScript)Next Question:  Yahoo Board Personally Liable  [H]ard|OCP Front Page News
Question JS Print script ( kirupaForum Client Side (HTML, CSS, JavaScript) )
Updated: 2009-01-01 14:10:25 (2)
JS Print script

Hi, I needed some help with a print script.

I'm using a traditional script for this, my script is:

function imprSelec(nombre)
{
var ficha = document.getElementById(nombre);
var ventimp = window.open(' ', 'popimpr');
ventimp.document.write( ficha.innerHTML );
ventimp.document.close();
ventimp.print( );
ventimp.close();
}

The thing is that when the person click on the print button, the HTML that pops up looses the style and template... is there a way o a script so this doesn't happen?. The thing is that a need a popup because the script is suppose to print a content html and not the hole page that has a template and thing I don't want to print...

Any help is welcome!!!... Thanks

Miguel

Answers: JS Print script ( kirupaForum Client Side (HTML, CSS, JavaScript) )
JS Print script

yes it is quite possible:

make a html file something like:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

</head>
<style type="text/css" >
<!--
.div_style
{
background: blue;
}
-->
</style>
<body>
<div class='div_style' id='print_text'>testing popup</div>

</body>
</html>

the div is used to put the text in that should be printed.

now change the functions:
function imprSelec(nombre)
{
var ficha = document.getElementById(nombre);
var ventimp = window.open(' ', 'popimpr');
ventimp.document.write( ficha.innerHTML );
ventimp.document.close();
ventimp.print( );
ventimp.close();
}
to
function imprSelec(nombre)
{
var ficha = document.getElementById(nombre);
var ventimp = window.open('the_name_off_the_html_file_you_create d ', '_self');
ventimp.document.getElementById('print_text').inne rHTML = ficha.innerHTML;
ventimp.document.close();
ventimp.print( );
ventimp.close();
}

now you can apply every style you want inside the new html file...

borrob

JS Print script

depending on your needs you could also create a print only style sheet.

jel3

Previous Question:  JS page done loading  kirupaForum  Client Side (HTML, CSS, JavaScript)Next Question:  Yahoo Board Personally Liable  [H]ard|Forum  [H]ard|OCP Front Page News

- Source: JS Print script kirupaForum Client Side (HTML, CSS, JavaScript)
- Previous Question: JS page done loading kirupaForum Client Side (HTML, CSS, JavaScript)
- Next Question: Yahoo Board Personally Liable [H]ard|Forum [H]ard|OCP Front Page News