也许,有人能解释我,为什么">“符号被编码到">"。我正在使用mvc剃须刀,我的cshtml视图使用的脚本如下:
<script type="text/javascript" language="javascript">
$(document).ready(function () {
var thumbnails = $("img.thumbnail");
thumbnails.each(function () {
$(this).load(function () {
if ($(this).height() > $(this).width()) {
$(this).css("height", "100%");
}
else {
$(this).css("width", "100%");
}
});
});
});
</script>Chrome浏览器抛出异常:
Uncaught :意料之外的令牌;
在下一行:
if ($(this).height() > $(this).width()) {做这种编码/转换的原因是什么(除了手的曲线:D)?
或者用什么方法解决这个问题。
发布于 2011-04-25 19:21:26
试一试
<script type="text/javascript" language="javascript">
<![CDATA[
$(document).ready(function () {
var thumbnails = $("img.thumbnail");
thumbnails.each(function () {
$(this).load(function () {
if ($(this).height() > $(this).width()) {
$(this).css("height", "100%");
}
else {
$(this).css("width", "100%");
}
});
});
});
]]>
</script>否则,将javascript放在外部javascript文件中。
(我在阅读了你的问题评论后发布了这个答案)
https://stackoverflow.com/questions/5782038
复制相似问题