Different behaviors while using localhost and server name

烈酒焚心 提交于 2019-12-20 05:54:35

问题


I wanted to drag an image around inside a div, which I did using the jQuery UI draggable function.

HTML:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="jQuery/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="jQuery/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>
<script>
    $(document).ready(function () {
        $('#dragme').draggable();
    });
</script>
</head>
<body>
<div id="container" style="width:300px;height:300px;overflow:hidden;margin:auto;border:solid 1px black">
    <img src="http://img.thesun.co.uk/multimedia/archive/01650/greats_1650266a.jpg" id="dragme" />    
</div>
</body>
</html>

You can see the demo here. Works fine, however, the problem started when I hosted the same on IIS. When I use http:// localhost/mysite, the page works fine on Chrome and IE, however when I use http:// servername/mysite, on IE, the page goes for a toss. The entire image is shown on the div. (Snapshot).

I can still drag the image around, though.

I fail to understand why this happens. I have encountered problems in the past as well where the behavior of http:// localhost/mysite and http:// servername/mysite have been different.

Can anyone please explain why this is happening? Thanks in advance.


回答1:


IE loads local web applications in compatibility view (IE9+) while external websites are being loaded in IE9+ standards view. This is the reason why you see your website locally in IE7 document mode. You can change this by hitting F12 and changing to IE9 document mode. If you want to make your IE load local site in regular view go to tools -> compatibility view settings and delete localhost from there.



来源:https://stackoverflow.com/questions/14252202/different-behaviors-while-using-localhost-and-server-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!