Probably, someone will be able to explain me, why ">" sign is encoded to ">"
.
I am using开发者_如何学编程 mvc razor and some my cshtml view uses script that you can find below:
<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 browser throws exception:
Uncaught SyntaxError: Unexpected token ;
in next line:
if ($(this).height() > $(this).width()) {
What reason(s) can be to do this encoding/transform (except for curves of hands :D)?
Or some way to solve it.
Try
<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>
Or else put your javascript in an external javascript file.
(I post this answer having read your question comments)
精彩评论