window.print not working with opera browser

前端 未结 2 1281
有刺的猬
有刺的猬 2021-01-24 05:26

I am trying to open a print dialog box in Opera browser using javascript code as



        
相关标签:
2条回答
  • 2021-01-24 05:41

    You need to make sure the whole web page is loaded in Opera before you call window.print();

    So using this may help - not, I am waiting for the page to load AND causing a slight delay, which is a little known fix for some versions of Opera.

    Hope it helps.

    window.onload = function () {
        window.setTimeout(function () {
            window.print();
        }, 500);
    }
    
    0 讨论(0)
  • 2021-01-24 05:55

    Try putting your code in load event:

    <script language=javascript>
    window.onload = function(){
      window.print();
    };
    </script>
    
    0 讨论(0)
提交回复
热议问题