开发者

how to pass javascript function argument within JSF component?

I have the folowing code:

<script Language="JavaScript">
function load(url) {
var load = window.open(url,开发者_如何转开发'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}
</script>
<h:commandLink value="aaa" onclick="load('<h:outputText value="http://www.google.com" /> '); />

I want to pass attribute in JS function but probably inside onclick is not the right way.

Any solution?


This should work out:

<h:commandLink value="aaa" onclick="load('http://www.google.com')" />


If you're using Facelets, then you can just use EL in template text.

<h:commandLink value="aaa" onclick="load('#{bean.url}'); />

If you're still on JSP, then you really need to print it as a JS variable.

<script>
    var url = '<h:outputText value="#{bean.url}" />';
</script>

Alternatively you can also use plain vanilla HTML:

<a href="#" onclick="load('<h:outputText value="#{bean.url}" />')">aaa</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜