在脚本标签中是否有必要使用CDATA标签,如果是这样的话?
换句话说,何时何地:
<script type="text/javascript">
//<![CDATA[
...code...
//]]>
</script>
Run Code Online (Sandbox Code Playgroud)
比这更好:
<script type="text/javascript">
...code...
</script>
Run Code Online (Sandbox Code Playgroud) 作为这个问题的扩展,我试图将Javascript插入到已经呈现ajax表<h:commandButton />的onclick属性action中.
我想做什么:在列表框中获取所选项目并将其转换为要在JSF中使用的参数FileServlet.即para2=value1¶m=value2¶m=value3
这就是我所拥有的:
<script type ="text/javascript">
function myScript() {
var box = document.getElementbyId('myForm:box');
var length = box.options.length;
var paramstring = "";
for (var i = 0; i < length; i++) {
if (i != (length - 1) {
if (box.options[i].selected) {
paramstring = paramstring + "param=" + box.options[i].value + "&";
}
} else {
paramstring = paramstring + "param=" + box.options[i].value;
}
}
if (document.getElementById('myForm:checkbox').checked) {
window.location='fileServlet? + …Run Code Online (Sandbox Code Playgroud) 在一次采访中,我被问到了一个我从未想过的问题,即"我们已经拥有满足编写网页所有要求的HTML,那么XHTML的需求是什么?"
我用Google搜索了很多文章并阅读了很多文章,但我无法理解为什么会引入XHTML.请向我解释.