AMS*_*AMS 6 javascript c# asp.net jquery json
<!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>
Run Code Online (Sandbox Code Playgroud)
以上是我的带有jquery脚本的aspx代码,它给出了窗口的高度和宽度.
当我从visual studio运行web应用程序时,这个代码在所有浏览器上完全正常 http://localhost/Mypage.aspx
但是当我在iis上托管它并使用我的机器名运行http://MyMachine/Mypage.aspx它会给JSON未定义,而属性"$"是null或未定义的错误.(这只是在IE 10(非兼容模式),对于chrome它工作正常)
问题1)我们是否需要处理IE 10的任何安全限制?
问题2)当我在iis上托管它并在我自己的机器上运行机器名时,为什么会这样?
问题3)我错过任何jquery refrence.
问题4)明显的一个,解决这个问题的任何方法.
小智 3
按照许多人的建议使用元标记。
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Run Code Online (Sandbox Code Playgroud)
但我想给出一个重要的提示。mata 标签应该是 head 标签中的第一个标签。我读过它的一些地方,如果它不是第一个标签,它就不会产生效果。