humbleprogrammer
Programmer
Hello,
I have a function that hides certain elements in a page, changes the background to white and is supposed to change the font color to black when the page is printed. Everything works except it doesn't change the font color. Below is my code. Can someone glance it over and shed some light?
<script>
function simplealert(){
//Fires off the alert in the body tag.
alert('Commenced printing!')
}
window.onbeforeprint=simplealert
function printformat(){
//Make the document background white and font black
document.bgColor="white"
document.body.style.background="white"
document.body.style.color="black"
//store all elements with id=remove to "remove_el"
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.style.display='none'
}
}
function revertback(){
//Reload the window
setTimeout("window.location.reload()",50)
}
window.onbeforeprint=printformat
window.onafterprint=revertback
</script>
Thanks in advance!
I have a function that hides certain elements in a page, changes the background to white and is supposed to change the font color to black when the page is printed. Everything works except it doesn't change the font color. Below is my code. Can someone glance it over and shed some light?
<script>
function simplealert(){
//Fires off the alert in the body tag.
alert('Commenced printing!')
}
window.onbeforeprint=simplealert
function printformat(){
//Make the document background white and font black
document.bgColor="white"
document.body.style.background="white"
document.body.style.color="black"
//store all elements with id=remove to "remove_el"
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.style.display='none'
}
}
function revertback(){
//Reload the window
setTimeout("window.location.reload()",50)
}
window.onbeforeprint=printformat
window.onafterprint=revertback
</script>
Thanks in advance!