2012-09-12 24 views
3
整合

大家, 我都面臨着一個問題:有些錯誤在IE約ZK和JavaScript

的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,無法完成操作。(錯誤)

是否有解決此問題的方法?非常感謝你 !!!

回答

1

您可以使用Executions.getCurrent().sendRedirect(string, string)javadocs做到這一點的服務器端。但是對於這樣一個簡單的要求,你不需要去服務器。對客戶端的按鈕onClick事件使用ZK的client namespace,你可以叫你的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>  
+1

非常感謝您的回答。我嘗試你在IE8的方法,「Execution.getCurrent ......」是確定的,但它無法控制窗口大跌眼鏡的大小。第二種方法「W:的onClick =‘的testAlert();’」會導致:org.xml.sax.SAXParseException:前綴「w」表示屬性「W:的onClick」與元素類型的「按鈕」相關聯的未綁定。 – Gallery

+1

我再試一次,你是對的!上次,我忘記了xmlns:w =「client」。非常感謝你! – Gallery