开发者

script validation error

开发者 https://www.devze.com 2022-12-26 11:06 出处:网络
there is a script in my html tag <script type=\"text/javascript\"> function setTaxDisplay(display)

there is a script in my html tag

<script type="text/javascript">
 function setTaxDisplay(display)
 {
  window.location.href += (window.location.href.indexOf('?') > -1 ? '&' : '?') + 'taxInclude=' + display;
 }
</script>

When passed to validation It returns that the ampersand there isn't valid, but it's absolutely vital to the function of the page, is there a way I can make the validator ignore this? I don't need to validate the p开发者_Python百科age, I'm no JS expert at all I'm not sure if I can replace it with &amp;.

Thanks.


You are probably writing XHTML and serving it as text/html. Welcome to the joys of pretending one markup language is really another one.

You can wrap the script with commented out CDATA markers, but you should move it to an external file.

See http://www.w3.org/TR/xhtml-media-types/#C_4 for details and examples.

Alternatively — just write HTML. XHTML doesn't give benefits to most authors (and since your problem is with validation rather then with any of the tools you are using, you probably aren't one of the authors who does benefit from using XHTML)

0

精彩评论

暂无评论...
验证码 换一张
取 消