tags:

views:

33

answers:

2

Hello everybody!

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?

A: 

This should work out:

<h:commandLink value="aaa" onclick="load('http://www.google.com')" />
Mr.Expert
I imagine that he actually want to print a bean property. It would have been *too* obvious otherwise, Mr. Expert.
BalusC
A: 

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>
BalusC