日期:2014-05-17  浏览次数:20689 次

java打印功能在ie6下失效的问题

function Printpart(id_str)//id-str 内容中的id
          {
                var el = document.getElementById(id_str);
                var iframe = document.createElement('IFRAME');
                var doc = null;
                iframe.setAttribute('style', 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
                document.body.appendChild(iframe);
                doc = iframe.contentWindow.document;
                doc.write('<div>' + el.innerHTML + '</div>');
                doc.close();
                iframe.contentWindow.focus();
                iframe.contentWindow.print();
                if (navigator.userAgent.indexOf("MSIE") > 0)
                {
                     document.body.removeChild(iframe);
                }
                return false;
          }


ie6提示脚本错误
URL:xxx/6hdoclc/preview.dlg

------解决方案--------------------
IE6太老了,不必为它再兼容吧