<!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运行Web应用程序时,无论在任何浏览器上,这段代码都可以正常工作:http://localhost/Mypage.aspx
但是,当我将其放在IIS上,并使用我的机器名称来运行http://MyMachine/Mypage.aspx
时,它会在IE 10(非兼容模式)中出现JSON未定义以及"$"属性为null或未定义的错误(在Chrome中没有此问题)。
问题1:我们需要考虑IE 10的任何安全限制吗?
问题2:为什么在我的机器上使用机器名称运行时会出现这种情况?
问题3:我是否遗漏了任何JQuery引用?
问题4:显然的问题,有没有解决这个问题的方法?
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
。 - I4V