IE中关于ZK和JavaScript集成的一些错误

Some error in IE about the integration of ZK and JavaScript

本文关键字:集成 错误 JavaScript ZK IE      更新时间:2023-09-26

每个人,我遇到了一个问题:

ZUL代码:

<window title="Hello World!!" id="winMain" border="none" width="100%" height="100%">
<script type="text/javascript"> 
<![CDATA[
function testAlert() { 
window.open ("http://cn.bing.com", "Show", "menubar=0,resizable=1,location=0,width=683,height=384");} 
]]>
</script>
<div align="center">
<button id="btnShow" label="Show">
<attribute name="onClick">
    <![CDATA[ 
        Clients.evalJavaScript("testAlert()");
    ]]>
</attribute>
</button>
</div>
</window>

ZUL代码的功能是在一些浏览器中打开一个新窗口,它在CHROME、Firfox中运行良好。但当我在IE8中运行它时,会出现一些错误:

客户端错误:无法处理脚本;由于错误80020101,无法完成操作。(错误)

这个问题有什么解决办法吗?非常感谢!!!

您可以在服务器端使用Executions.getCurrent().sendRedirect(string, string) javadocs来完成此操作。但对于这样一个简单的需求,您不需要转到服务器。使用ZK的客户端名称空间,您可以在客户端的按钮onClick事件上调用testAlert()函数。这两种方法都显示在下面的代码中,它在IE 8(标准模式)上工作

<window title="Hello World!!" id="winMain" border="none" width="100%" height="100%" xmlns:w="client">
<script type="text/javascript"> 
<![CDATA[
function testAlert() { 
window.open ("http://cn.bing.com", "Show", "menubar=0,resizable=1,location=0,width=683,height=384");} 
]]>
</script>
<div align="center">
<button id="btnShow" label="Show 1">
<attribute name="onClick">
    <![CDATA[ 
        Executions.getCurrent().sendRedirect("http://cn.bing.com", "_blank");
    ]]>
</attribute>
</button>
<button id="btnShow2" label="Show 2" w:onClick="testAlert();">
</button>
</div>
</window>