是的,想让其关闭后显示其中的Div;有何解决办法呢?

解决方案 »

  1.   

    begin<div id=demo>
    打印的时候没有
    </div>end
    <script>
    function window.onbeforeprint(){
    demo.style.display="none"
    }
    function window.onafterprint(){
    demo.style.display=""
    }
    </script>
      

  2.   

    <style>
    @media print{#demo {display:none}}
    </style>
    begin<div id=demo>
    打印的时候没有
    </div>end
      

  3.   

    begin<div id=demo>
    打印的时候没有
    </div>end<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
    </object>
    <input type="button" name="Button" value="打印预览" onClick="demo.style.display='none';document.all.WebBrowser.ExecWB(7,1);demo.style.display='';">
      

  4.   

    非常感谢qiushuiwuhen(秋水无恨) 
    再请教一下:
    在onclick事件中:
    这个demo.style.display=''能不能放到外面来?
    即与document.all.WebBrowser.ExecWB(7,1);分离,写在不同的地方
      

  5.   

    这样的语法不大理解,请解释一下。
    <style>
    @media print{#demo {display:none}}
    </style>
    还有,如果在点击关闭的时候,还是做其它的操作呢?比如,在预览之前,隐藏了很多按钮,点击关闭后,要将这些按钮显示出来,除了第二种写法外,还有什么办法吗?
      

  6.   

    <style>
    @media screen{.hs {display:none}}
    @media print{.hp {display:none}}
    </style>
    begin
    <div class=hp>打印的时候没有</div>
    <button class=hs>打印的时候才有</button>
    <input class=hs value=打印的时候才有>
    end
      

  7.   

    其实这些都不是“点击关闭”后发生的,是“点击打印”之后弹出来打印预览窗口后就发生了,由于预览窗口锁定了焦点,所以看起来是一样的。-----------------------------------------------------------------
    begin <div id=demo>
    打印的时候没有
    </div> end<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
    </object>
    <input type="button" name="Button" value="打印预览" onClick="demo.style.display='none';document.all.WebBrowser.ExecWB(7,1);demo.style.display='';alert('打印窗口还开着,可是脚本运行完了');">
    -----------------------------------------------------------------
    我一开始就在奇怪,有什么事情非要在“关闭打印预览窗口返回本页面”时运行呢?