3

大家,我遇到了一个问题:

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,无法完成操作。(错误)

这个问题有解决方案吗?非常感谢你 !!!

4

1 回答 1

1

您可以使用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>    
于 2012-09-13T06:26:59.353 回答