解决IE浏览器的only one scriptx object can be used per browser window问题
来源:互联网 发布:数据库原理与应用 编辑:程序博客网 时间:2024/05/18 00:15
浏览器:IE
问题:浏览器报only one scriptx object can be used per browser window错误
一般的ScriptX控件的引入需要在当前文件的中这样写:
<object id="factory" style="display: none" viewastext="" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="../../smsx.cab#Version=6,5,439,30"> </object>
但当你在一个窗口内连续打开两个要打印的文档时,只能有一个打印文件能正常打印,另一个是打印不了也预览不了的,报only one scriptx object can be used per browser window的错误,原因是每个浏览器窗口只能有一个ScriptX对象,而你在一个浏览器窗口下打开了2个以上的打印文件,每个 打印文件中都引入了打印对象,所以会报错,要想解决这个问题,首先就得考虑决不能让每个打印文件都引入ScriptX对象,所以我没有将上面那段代码写到当前文件,而是引入一个外部js文件,这个文件中包含创建ScriptX对象及打印格式内容,js文件的内容如下(原理:打印前引入ScriptX对象,打印后清除掉)
//预览function Preview() { if(!document.getElementById("inScriptX")){ var scriptX=document.createElement("div"); scriptX.id="inScriptX"; document.body.appendChild(scriptX); } //预览前动态的创建ScriptX对象 document.getElementById("inScriptX").innerHTML="<object id='factory' style='display:none' viewastext classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814' codebase='../../smsx.cab#Version=6,5,439,30'></object>"; if (!factory.object) { alert("打印控件没有正确安装!"); return false; } set_print(); document.getElementById("factory").printing.Preview(); //预览后立刻清除 document.getElementById("inScriptX").innerHTML="";}//打印function Print() { try{ if(!document.getElementById("inScriptX")){ var scriptX=document.createElement("div"); scriptX.id="inScriptX"; document.body.appendChild(scriptX); }//打印前动态的创建ScriptX对象 document.getElementById("inScriptX").innerHTML="<object id='factory' style='display:none' viewastext classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814' codebase='../../smsx.cab#Version=6,5,439,30'></object>"; if (!factory.object) { alert("打印控件没有正确安装!"); return false; } set_print(); factory.printing.Print(false); //打印后立刻清除 document.getElementById("inScriptX").innerHTML=""; }catch(e){ alert(e.message) }}//设置打印样式 function set_print(){ factory.printing.header = "" factory.printing.footer =""; factory.printing.leftMargin = 6;//左边距 factory.printing.topMargin = 0;//上边距 factory.printing.rightMargin =6;//右边距 factory.printing.bottomMargin = 10;//下边距 }
这样就可以在一个浏览器窗口同时打开多个要打印的文件并都能正常打印了!
0 0
- 解决IE浏览器的only one scriptx object can be used per browser window问题
- 解决IE浏览器的only one scriptx object can be used per browser window问题
- 解决IE浏览器的only one scriptx object can be used per browser window问题
- QUESTION 132 Only one LONG column can be used per table
- [Visual Studio 2010]如何解决错误CoClass 'xx' can be used only as one of its applicable interfaces
- mysql报there can be only one auto column的问题原因
- ActionBarImpl can only be used with a compatible window decor layout
- java.lang.IllegalStateException: ActionBarImpl can only be used with a compatible window decor layou
- java.lang.IllegalStateException: ActionBarImpl can only be used with a compatible window decor layou
- Python SQLite3的问题sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in th
- Only one Looper may be created per thread
- Only one Looper may be created per thread
- -pie can only be used when targeting iOS 4.2 or later错误解决
- 解决PyQt错误(QObject::startTimer: QTimer can only be used with threads started with QThread)
- ANR Warning,RemoteViews can only be used once ,if not 问题
- 关于Pods written in Swift can only be integrated as frameworks问题的解决
- Null pointer access: The variable al can only be null at this location问题的解决
- QT “Timers can only be used with threads started with QThread”的解决办法~
- Android Service 官方解释
- JavaEE框架Bootstrap HTML5 jQuery SpringMVC maven mybatis
- 无监督特征学习(半监督学习+自学习)
- 记录Gerrit2.8.4环境迁移、安装、配置以及问题解决
- Couldn't load native-lib from loader dalvik使用cmake编译
- 解决IE浏览器的only one scriptx object can be used per browser window问题
- ionic开发---ios上点击输入框,失去焦点的时候,页面白屏
- ajax多条件查询动态分页
- Java读取ini方法
- android studion升级后以及打开其他项目打不开
- c语言将数据写入文件(用链表实现)
- 堆排序的实现
- 第一天记事
- 剑指offer 二叉树镜像