I am currently using Confluence 4.3 and I'm trying to add either an HTML button or HTML link that will invoke a javascript function.
How can this be achieved?
Specifically, there is a file called "searchpanel.vm" within Confluence which is a simple velocity template that defines criteria used to refine your confluence searches.
I wish to a button in the search panel that will invoke a javascript function. How do I do this?
There is no special notation for writing Javascript in Velocity. Just write as you normally do in any HTML file. An example would be :
<form>
#if ($searchVisible)
<div id = "searchLinkContainer" >
<a href="javascript:searchFunction()">Click here</a> to search.
</div>
#end
</form>
<script language="JavaScript" type="text/javascript">
function searchFunction () {
//Do search
}
</script>
Note that if you include the tag inside a conditional statement in Velocity and it doesn't get traversed, the script will not be available in the HTML page.
Velocity is just a templating language/engine, which can print whatever you want. Just write the HTML that you would normally use regardless of the fact that you're in a .vm
file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.