amalpartout
07-15-2007, 02:36 PM
Hello,
I am French. sorry if my english is bad.
I have a problem. I want remove somethink in web page befor printing. I found some exemple but it work with IE7 but it don't work with Firefox.
<!-- DEBUT REMOVE PRINT-->
<!--http://www.javascriptkit.com/-->
<script language="JavaScript">
function removeelements(){
//store all elements with id=remove to "remove_el"
var remove_el=document.write.remove
var remove_el=document.all.remove
//if there is only one element with id=remove
if (remove_el!=''&&remove_el.length==null)
remove_el.style.display='none'
else{
//for each element with id=remove
for (i=0;i<remove_el.length;i++)
remove_el[i].style.display='none'
}
}
function revertback(){
setTimeout("window.location.reload()",50)
}
window.onbeforeprint=removeelements
window.onafterprint=revertback
</script>
<!-- FIN REMOVE PRINT-->
I know that "window.onbeforeprint" is not supported by firefox. it work well with IE7. I put id=remore in each balise
I have a second solution but I don't know how it don't work
<link href="afpca.css" rel="stylesheet" type="text/css" />
<link href="imprimante.css" rel="stylesheet" type="text/css" media="print" />
in file imprimante.css i write :
#remove {
display: none;
}
my print button ;
<input name="Imprimez" onclick="window.print()" class="formbutton" id="Imprimez" value="Imprimez" type="button" />
It don't do anythink . grrr !! but if I use "imprimante.css" with using google developpers toolbar it's ok.
Please , what I miss in my web page
Thank you very much for answers.
Amalpartout
I am French. sorry if my english is bad.
I have a problem. I want remove somethink in web page befor printing. I found some exemple but it work with IE7 but it don't work with Firefox.
<!-- DEBUT REMOVE PRINT-->
<!--http://www.javascriptkit.com/-->
<script language="JavaScript">
function removeelements(){
//store all elements with id=remove to "remove_el"
var remove_el=document.write.remove
var remove_el=document.all.remove
//if there is only one element with id=remove
if (remove_el!=''&&remove_el.length==null)
remove_el.style.display='none'
else{
//for each element with id=remove
for (i=0;i<remove_el.length;i++)
remove_el[i].style.display='none'
}
}
function revertback(){
setTimeout("window.location.reload()",50)
}
window.onbeforeprint=removeelements
window.onafterprint=revertback
</script>
<!-- FIN REMOVE PRINT-->
I know that "window.onbeforeprint" is not supported by firefox. it work well with IE7. I put id=remore in each balise
I have a second solution but I don't know how it don't work
<link href="afpca.css" rel="stylesheet" type="text/css" />
<link href="imprimante.css" rel="stylesheet" type="text/css" media="print" />
in file imprimante.css i write :
#remove {
display: none;
}
my print button ;
<input name="Imprimez" onclick="window.print()" class="formbutton" id="Imprimez" value="Imprimez" type="button" />
It don't do anythink . grrr !! but if I use "imprimante.css" with using google developpers toolbar it's ok.
Please , what I miss in my web page
Thank you very much for answers.
Amalpartout