当我在w3c上验证时,以下脚本会出错 [英] following script gives error when i validate on w3c

查看:66
本文介绍了当我在w3c上验证时,以下脚本会出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript">
ddaccordion.init({
    headerclass: "submenuheader", //Shared CSS class name of headers group
    contentclass: "submenu", //Shared CSS class name of contents group
    revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
    mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
    defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
    onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
    animatedefault: false, //Should contents open by default be animated into view?
    persiststate: true, //persist state of opened contents within browser session?
    toggleclass: ["", "active"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["suffix", "<img src="images/plus.gif" class="statusicon" alt=" " />", "<img src="images/minus.gif" class="statusicon" alt=" " />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
        //do nothing
    },
    onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
        //do nothing
    }
})
</script>







在上面的脚本中,w3c发生以下错误



文件类型不允许元素img在这里

... plus.gifclass =statusiconalt =/>,< img src =images / minus.gifclass =...




In above script following error occur on w3c

document type does not allow element "img" here
…plus.gif" class="statusicon" alt=" " />", "<img src="images/minus.gif" class="…

推荐答案

您在构建图像标记的字符串值方面遇到了问题。你的引号会混淆javascript解释器。文字字符串中的引号需要转义。

You hava a problem in the way the string value for your image tag is constructed. Your quotes will confuse the javascript interpreter. The quotes inside the literal strings need to be escaped.
togglehtml: ["suffix", "<img src="images/plus.gif" class="statusicon" alt=" " />", "<img src="images/minus.gif" class="statusicon" alt=" " />"]



应为


should be

togglehtml: ["suffix", "<img src=\"images/plus.gif\" class=\"statusicon\" alt=\" \" />", "<img src=\"images/minus.gif\" class=\"statusicon\" alt=\" \" />"]


这篇关于当我在w3c上验证时,以下脚本会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆