illegal character错误解决办法

如过你在asp.net后台生成html代码然后输出到客户端就可能发生错误。

错误的写法:

onmouseover='currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff ' '

this.style.backgroundColor='#6699ff '此处脚本会认为它是非法的字符串不给予通过,就是提示:illegal character

正确写法:

onmouseover='currentcolor=this.style.backgroundColor;this.style.backgroundColor=\"#6699ff\"  '

this.style.backgroundColor;this.style.backgroundColor=\"#6699ff\" 此处加上转义符就可以了。

posted @ 2011-07-04 15:07  txsun  阅读(2753)  评论(0编辑  收藏  举报