如何调用ZK中的javascript函数?

时间:2022-03-15 16:58:28

In ZK framework, inside zul file i want to call javascript function but it does not happens.

在ZK框架中,在zul文件中,我想调用javascript函数,但它不会发生。

<a label="Click" onClick="popUp();">

I have that popUp() function also. But when I click on

我还有popUp()函数。但当我点击

<script type="text/javascript">
    function createPopUp(url)
    {
        var w = 600;
        var h = 500;
        var left = (screen.width/2)-(w/2);
        var top = (screen.height/2)-(h/2);
        window.open(url,'name','scrollbars=yes,width='+w+', height='+h+', top='+top+', left='+left);
    }
</script>

But when I click on that link it dispalys following error:

但当我点击这个链接时,它会显示以下错误:

Sourced file: inline evaluation of: `` popUp();'' : 
Command not found: popUp() : at Line: 13 : 
in file: inline evaluation of: `` popUp();'' : popUp ( ) 

2 个解决方案

#1


1  

As an alternative, if you want to achieve this in java, rather than .zul file, you can use

作为一种替代方法,如果您希望在java而不是.zul文件中实现这一点,可以使用

label.setWidgetListener(Events.ON_CLICK, "popUp();");

as indicated here with javadoc

正如这里的javadoc所示

#2


7  

To solve this problem I found below way:

为了解决这个问题,我发现以下方法:

<a label="Click" xmlns:w="http://www.zkoss.org/2005/zk/client" w:onClick="createPopUp('http://www.facebook.com/prabhatsubedi');"/>

#1


1  

As an alternative, if you want to achieve this in java, rather than .zul file, you can use

作为一种替代方法,如果您希望在java而不是.zul文件中实现这一点,可以使用

label.setWidgetListener(Events.ON_CLICK, "popUp();");

as indicated here with javadoc

正如这里的javadoc所示

#2


7  

To solve this problem I found below way:

为了解决这个问题,我发现以下方法:

<a label="Click" xmlns:w="http://www.zkoss.org/2005/zk/client" w:onClick="createPopUp('http://www.facebook.com/prabhatsubedi');"/>