\" sign is encoded to \">\". I am using开发者_如何学编程 mvc razor and some my cshtml view uses script that you can find below:" />
开发者

">" is encoded to ">"

开发者 https://www.devze.com 2023-02-28 09:51 出处:网络
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:

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() &gt; $(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)

0

精彩评论

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