Web Analytics Made Easy -
StatCounter onafterprint() - CodingForum

Announcement

Collapse
No announcement yet.

onafterprint()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • onafterprint()

    Hi folks,

    I'm looking for some advice please. I'm using javascript to print a web page. I remove the unwanted parts (buttons ect) before printing, then restore them and redisplay the page after printing, but....

    I get the following IE message when I use onafterprint.

    "The page canot be refreshed without resending the information."

    If I click retry or cancel it returns to the original page as expected. I want to be able to go straight from the original page to the print page and back to the original without seeing the refresh message.

    This is the scripting I use.

    <script language="JavaScript">

    function removeElements(){
    //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[i].style.display='none'
    }
    }

    function revertBack(){
    setTimeout("window.location.reload()",50)
    }

    window.onbeforeprint=removeElements
    window.onafterprint=revertBack

    </script>

    I'm using an Apache server with perl/CGI

    Cheers

    Calum
Working...
X