【发布时间】:2013-09-15 01:37:48
【问题描述】:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Hello World</title>
<link href="StyleSheet.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="Scripts/jquery-2.0.3.js">
$(document).ready(function () {
<%--$("#width").val() = $(window).width();
$("#height").val() = $(window).height();--%>
});
</script>
<script type="text/javascript">
$(document).ready(function () {
$("#width").val($(window).width());
$("#height").val($(window).height());
});
</script>
</head>
<body>
<form id="form1" runat="server">
<input id="width" type="hidden" runat="server" />
<input id="height" type="hidden" runat="server" />
</form>
</body>
</html>
上面是我的带有 jquery 脚本的 aspx 代码,它给出了窗口的高度和宽度。
当我从 Visual Studio http://localhost/Mypage.aspx 运行 Web 应用程序时,此代码在所有浏览器上都非常好
但是当我将它托管在 iis 上并使用我的机器名称 http://MyMachine/Mypage.aspx 运行时,它给出 JSON 未定义并且属性“$”为空或未定义错误。(这仅在 IE 10(非兼容模式)中,对于铬它工作正常)
问题 1) 我们是否需要处理 IE 10 的任何安全限制?
问题2)为什么当我将它托管在iis上并在我自己的机器上使用机器名运行它时会发生这种情况?
问题 3)我是否缺少任何 jquery 参考。
问题 4) 很明显,这个问题的任何解决方案。
【问题讨论】:
-
是的,我说过,即使在部署后它在 Chrome 上也能正常工作。这是IE的问题。
-
我也想试试
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> -
酷它工作。谢谢。你能帮我理解或指点一下那一行代码是如何解决问题的吗?
-
我猜,默认情况下,您的 IE 工作在较低版本的兼容模式下,而不是 IE10。
-
我已经检查了开发者工具 I4V,它在 IE 10 中运行。
标签: c# javascript jquery asp.net json