WebBrowser.ExecWB 不报错不响应,该如何处理
WebBrowser.ExecWB 不报错不响应
function doPrint(str){
// var width=Math.round((window.screen.width-400)/2);
// var height=Math.round((window.screen.height-200)/2);
// var w=window.open("_blank",
// "height=100, width=400, top="+(height-100/2)+",left="+(width-400/2)+", toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
var w=window.open("", "_blank", " toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
w.document.write(str);
// w.print();
w.document.body.insertAdjacentHTML("beforeEnd",
"<object id=\"WebBrowser\" width=0 height=0 \ classid=\"clsid: 8856F961-340A-11D0-A96B-00C04FD705A2\">");
//alert(w.document.all.WebBrowser);
//w.document.all.WebBrowser.ExecWB(6,1);
//w.document.all.WebBrowser.ExecWB(6,2);
w.document.close();
w.document.all.WebBrowser.ExecWB(6,1);
w.close();
}
我在一个jsp页面打开一个空白页面并写入str然后调用WebBrowser.ExecWB打印,没有响应页面也没有报错信息。
windows安全设置和版本如图

顺便请问我紫色部分代码,在ie中为什么打开的还是最大化的窗口,我明明设置了大小还有显示位置。
------解决思路----------------------
参数数量不对,open(url,obj,参数)
------解决思路----------------------

------解决思路----------------------
object对象后面要以</OBJECT>结束,像iframe也是要以</iframe>结束,不然
function doPrint(str){
// var width=Math.round((window.screen.width-400)/2);
// var height=Math.round((window.screen.height-200)/2);
// var w=window.open("_blank",
// "height=100, width=400, top="+(height-100/2)+",left="+(width-400/2)+", toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
var w=window.open("", "_blank", " toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
w.document.write(str);
// w.print();
w.document.body.insertAdjacentHTML("beforeEnd",
"<object id=\"WebBrowser\" width=0 height=0 \ classid=\"clsid: 8856F961-340A-11D0-A96B-00C04FD705A2\">");
//alert(w.document.all.WebBrowser);
//w.document.all.WebBrowser.ExecWB(6,1);
//w.document.all.WebBrowser.ExecWB(6,2);
w.document.close();
w.document.all.WebBrowser.ExecWB(6,1);
w.close();
}
我在一个jsp页面打开一个空白页面并写入str然后调用WebBrowser.ExecWB打印,没有响应页面也没有报错信息。
windows安全设置和版本如图
顺便请问我紫色部分代码,在ie中为什么打开的还是最大化的窗口,我明明设置了大小还有显示位置。
------解决思路----------------------
参数数量不对,open(url,obj,参数)
------解决思路----------------------
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
</head>
<body>
</body>
</html>
<script type="text/javascript">
function doPrint(str){
var w=window.open("", "newWindow", " toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
w.document.write(str + "<object id=\"WebBrowser\" width=0 height=0 classid=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"><\/OBJECT>");
var t1= new Date();
var t2 = new Date();
//这里暂停一段时间,等待浏览器完成对象处理
while(t2-t1<1000){
t2=new Date();
}
w.document.all.WebBrowser.ExecWB(6,1);
w.close();
}
doPrint('str');
</script>
------解决思路----------------------
object对象后面要以</OBJECT>结束,像iframe也是要以</iframe>结束,不然