2010-04-02 59 views
0

我有一个简单的窗口,说明一个ZUL文件,其中包含与操作按钮:ZK:问题与JavaScript方法从动作调用谷歌浏览器

<?xml version="1.0" encoding="UTF-8"?> 
<zk xmlns:html="http://www.w3.org/1999/xhtml" 
    xmlns="http://www.zkoss.org/2005/zul" 
    xmlns:zk="http://www.zkoss.org/2005/zk" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"> 

    <window title="My First Window" border="normal" width="200px"> 
    <button label="click me" action="onclick:initObj()" /> 
     <script type="text/javascript" defer="true"> 
       function initObj() { 
        alert('initObj invoked'); 
        zkJScriptObject.init(); 
       } 
       zkJScriptObject = { 
        init: function() { 
        alert('init invoked'); 
        } 
       }; 
     </script> 
    </window> 
</zk> 

单击按钮成功调用JavaScript函数initObj()并在FireFox和IE中显示警报,但在Google Chrome中会导致错误“未捕获的ReferenceError:initObj未定义”。 您有什么建议吗,谷歌浏览器中这个问题的原因是什么?我该如何解决这个问题?

P.S.我正在使用ZK 3.6.3。

PPS。指定ZUL描述渲染成HTML代码:

<div id="zkau_798" z.type="zul.wnd2.Wnd2" z.autoz="true" class="z-window-embedded" style="width:200px;" 
    z.zcls="z-window-embedded" z.minheight="100" z.minwidth="200"> 
    <div class="z-window-embedded-tl"> 
     <div class="z-window-embedded-tr"></div> 
    </div> 
    <div class="z-window-embedded-hl"> 
     <div class="z-window-embedded-hr"> 
      <div class="z-window-embedded-hm"> 
       <div id="zkau_798!caption" class="z-window-embedded-header">My First Window</div> 
      </div> 
     </div> 
    </div> 
    <div id="zkau_798!cave" class=" z-window-embedded-cnt"> 
    <span z.type="zul.btn.Button" id="zkau_799" class="z-button" z.zcls="z-button"> 
     <table id="zkau_799!box" 
        cellspacing="0" 
        cellpadding="0" border="0" 
        class="z-button" 
        onclick="initObj()" 
        style="-webkit-user-select: none; "> 
     <tbody> 
      <tr> 
       <td class="z-button-tl"> 
        <button id="zkau_799!real" class="z-button"></button> 
       </td> 
       <td class="z-button-tm"></td> 
       <td class="z-button-tr"></td> 
      </tr> 
      <tr> 
       <td class="z-button-cl"></td> 
       <td class="z-button-cm">click me</td> 
       <td class="z-button-cr"> 
        <div></div> 
       </td> 
      </tr> 
      <tr> 
       <td class="z-button-bl"></td> 
       <td class="z-button-bm"></td> 
       <td class="z-button-br"></td> 
      </tr> 
     </tbody> 
    </table> 
    </span> 
     <script id="zkau_800" type="text/javascript" defer="defer"> 
      function initObj() { 
       alert('initObj invoked'); 
       zkJScriptObject.init(); 
      } 
      zkJScriptObject = { 
       init: function() { 
        alert('init invoked'); 
       } 
      }; 
     </script> 
    </div> 
</div> 
+0

您是否有产生acutal HTML输出我们应该能够计算出正在发生的事情......就目前而言,Chrome并不呈现ZK文件。 – Kinlan 2010-04-09 11:55:42

+0

@Kinlan 使用从指定的zul生成的html代码更新了我的文章。 – 2010-04-14 13:25:51

回答

相关问题