<!DOCTYPE html>
<html xmlns="">
<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>
the above is my aspx code with jquery script which gives the window height and width.
this code perfectly fine on all the browsers when i run the web app from visual studio http://localhost/Mypage.aspx
but when i host it on iis and run with my machine name http://MyMachine/Mypage.aspx
it gives JSON undefined and the Property "$" is null or undefined errors.( this is only in IE 10 (non-patibility mode) , for chrome it works fine)
question 1) do we need to take care of any security constraints for IE 10?
question 2) why does it happen this way when i host it on iis and run it with machine name on my own machine?
question 3) am i missing any jquery refrence.
question 4) obvious one, any solution to this problem.
<!DOCTYPE html>
<html xmlns="http://www.w3/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>
the above is my aspx code with jquery script which gives the window height and width.
this code perfectly fine on all the browsers when i run the web app from visual studio http://localhost/Mypage.aspx
but when i host it on iis and run with my machine name http://MyMachine/Mypage.aspx
it gives JSON undefined and the Property "$" is null or undefined errors.( this is only in IE 10 (non-patibility mode) , for chrome it works fine)
question 1) do we need to take care of any security constraints for IE 10?
question 2) why does it happen this way when i host it on iis and run it with machine name on my own machine?
question 3) am i missing any jquery refrence.
question 4) obvious one, any solution to this problem.
Share Improve this question asked Sep 11, 2013 at 6:36 AMSAMS 5506 silver badges22 bronze badges 5- yes i did,as i said it works fine on Chrome even after deploying. it is the problem with IE. – AMS Commented Sep 11, 2013 at 6:54
-
5
I would also try
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
– I4V Commented Sep 11, 2013 at 7:01 - Cool it worked. thanks. can u help me understand or give me a pointer how did that one line of code solved the problem? – AMS Commented Sep 11, 2013 at 7:12
- I guess, by default your IE works in a lower version patibility mode, not IE10. – I4V Commented Sep 11, 2013 at 7:21
- i have checked in the developer tools I4V, it is running in IE 10. – AMS Commented Sep 11, 2013 at 7:23
3 Answers
Reset to default 3use the Meta tag as suggested by many of the people.
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
but I want to give an importatnt tip. the mata tag should be the first tag in the head tag. I have read it some where if it is not the first tag it would not have its effect.
Are you sure you have the Scripts folder with jquery in the server? I suggest you to debug with fiddler and see if jquery is loaded correctly or if there is an http error.
as suggested by I4v, adding this to the header fixed the bug for me too:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Thanks guys