admin管理员组文章数量:1400762
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?
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?
Share Improve this question asked Dec 28, 2012 at 5:08 user1068636user1068636 1,9497 gold badges36 silver badges63 bronze badges 1- 1 you can just use a script tag and put a function call inside it, or use velocity to generate onload for document. there is nothing special to invoke js from velocity. – SriN Commented Dec 28, 2012 at 17:04
2 Answers
Reset to default 4There 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.
本文标签: How do you invoke javascript function from an apache velocity *vm fileStack Overflow
版权声明:本文标题:How do you invoke javascript function from an apache velocity *.vm file? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744280474a2598625.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论