How to include JavaScript file in JSF
2015-08-28 07:33
513 查看
In JSF 2.0, you can use
For example,
It will generate following HTML output…
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
It will generate following HTML output
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:outputScript />tag to render a HTML “script” element, and link it to a js file.
For example,
<h:outputScript library="js" name="common.js" />
It will generate following HTML output…
<script type="text/javascript" src="/JavaServerFaces/faces/javax.faces.resource/common.js?ln=js"> </script>
JSF outputScript example
An example to show you how to use<h:outputScript />to render a “
common.js“, see figure below :
JSF file
``"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h1>JSF 2 outputScript example</h1> <h:outputScript library="js" name="common.js" /> </h:body>
It will generate following HTML output
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
JSF 2 outputScript example
The JS file will render in where JSF `<h:outputScript />` tag is placed. ##Target Attribute In addition, you can use “`target`” attribute to control where to output the js file. - target=”head” – Display within the top of HTML head tag. - target=”body” – Display at the end of the body tag. - no target – Display at where the tag is placed. ##For example
It will generate following HTML output
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
JSF 2 outputScript example
```相关文章推荐
- JavaScript中为什么string可以拥有方法?
- JSF 2 graphicImage example
- JSF 2 outputText example
- JSF 2 multiple select dropdown box example
- JSF 2 dropdown box example
- JSF 2 multiple select listbox example
- JSF 2 listbox example
- JSF 2 radio buttons example
- javascript使用本地cookie
- [Javascript] Linting JavaScript with ESLint
- XML和JSON的对比
- javaScript的设计模式之单例模式
- [LeetCode][JavaScript]Single Number III
- js中(function(){…})()立即执行函数写法理解
- Jsp内置对象及EL表达式的使用
- 浅谈JavaScript中的string拥有方法的原因
- 谈谈JavaScript中function多重理解
- js实现横向伸展开的二级导航菜单代码
- javascript Array类型 方法大全
- JS实现仿苹果底部任务栏菜单效果代码