IE won't load PDF in a window created with window.open

后端 未结 2 1970
眼角桃花
眼角桃花 2021-02-19 13:25

Here\'s the problem, which only occurs in Internet Explorer (IE). I have a page that has links to several different types of files. Links from these files exe

相关标签:
2条回答
  • 2021-02-19 13:52

    I have solved this problem with an invisible iframe

    <div id="iframe" style="display: none">
      <iframe id="frm" style="display: none"></iframe>
    </div>
    

    And this logic here (using jquery):

    if ($.browser.msie && ($.browser.version &lt; 9.0)) {
      frm.location.href = href;
    }
    else {
      window.open(href);
    }
    

    The behaviour in my case is exactly as if the document was opened in a popup, as I'm using

    Content-Disposition: attachment; filename="document.pdf"
    
    0 讨论(0)
  • 2021-02-19 14:14

    try:

    function newwin(url,w,h) {
         var win = window.open("","temp","width="+w+",height="+h+",menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=auto,resizable=yes");
         win.location.href = url;
         win.focus();
    }
    
    0 讨论(0)
提交回复
热议问题