IE 10 上每个页面中的 Javascript 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14046857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript error in every page on IE 10
提问by Tony
My asp.net site is running well on IE6, IE7, IE8, IE9, Chrome, Safari, Firefox and Opera. But it is not working at all in IE10.
我的 asp.net 站点在 IE6、IE7、IE8、IE9、Chrome、Safari、Firefox 和 Opera 上运行良好。但它在 IE10 中根本不起作用。
If I click anywhere in the site (any button, any link, etc) it returns the following error:
如果我单击站点中的任何位置(任何按钮、任何链接等),它会返回以下错误:
SCRIPT5022: Sys.ArgumentOutOfRangeException: Value must be an integer.
Parameter name: x
Actual value was 5.999999523162842.
JS things, like tabs, doesnt work due to this problem. I tracked down the problem and it is in MicrosoftAjax.js , specifically in the following method.
由于这个问题,JS 的东西,比如选项卡,不起作用。我找到了问题,它在 MicrosoftAjax.js 中,特别是在以下方法中。
Sys.UI.Point = function Sys$UI$Point(x, y) {
/// <param name="x" type="Number" integer="true"></param>
/// <param name="y" type="Number" integer="true"></param>
/// <field name="x" type="Number" integer="true"></field>
/// <field name="y" type="Number" integer="true"></field>
var e = Function._validateParams(arguments, [
{name: "x", type: Number, integer: true},
{name: "y", type: Number, integer: true}
]);
if (e) throw e;
this.x = x;
this.y = y;
It works on all other IE versions since 6, which is quite a fate.
它适用于自 6 以来的所有其他 IE 版本,这是一种命运。
I know that HTML is only supported by real browsers, leaving out Internet Explorer, but my client really wants the site to work in IE10.
我知道 HTML 仅受真实浏览器支持,不支持 Internet Explorer,但我的客户确实希望该站点能够在 IE10 中运行。
Just to be clear, it works well in ie6 to 9, chrome, firefox and opera. None of them show javascript errors, just ie10, and this error comes up on every click. I copule not track who is calling this method. This is a big site and none of the js code that i use is calling it. I think that probably MicrosoftAjax.js framework has bound the click event and it is executing something but i am not sure what it is executing.
需要明确的是,它在 ie6 到 9、chrome、firefox 和opera 中运行良好。他们都没有显示javascript错误,只有ie10,每次点击都会出现这个错误。我 copule 不跟踪谁在调用这个方法。这是一个大站点,我使用的 js 代码都没有调用它。我认为 MicrosoftAjax.js 框架可能绑定了 click 事件并且它正在执行某些内容,但我不确定它正在执行什么。
Can anyone help me?
谁能帮我?
采纳答案by Tony
The answer is in the following link:
答案在以下链接中:
http://support.microsoft.com/kb/936993
http://support.microsoft.com/kb/936993
I had to change Microsoft.Ajax.js.
我不得不更改 Microsoft.Ajax.js。
回答by Mafu Josh
I found a nice solutionblogged by Yuriy:
<script language="javascript">
Sys.UI.Point = function Sys$UI$Point(x, y) {
x = Math.round(x);
y = Math.round(y);
var e = Function._validateParams(arguments, [
{name: "x", type: Number, integer: true},
{name: "y", type: Number, integer: true}
]);
if (e) throw e;
this.x = x;
this.y = y;
}
</script>
Paste this on your page to override the Sys$UI$Point function to round the numbers.
将此粘贴到您的页面上以覆盖 Sys$UI$Point 函数以对数字进行四舍五入。
Or, set <compilation debug="false">
或者,设置 <compilation debug="false">
Either of these worked for me.
这些都对我有用。
回答by Kelsey Abreu
Just to add to mafu josh's answer, the bound prototype can also be the issue.
只是为了补充mafu josh的答案,绑定原型也可能是问题所在。
Here's the code for that
这是代码
Sys.UI.Bounds = function Sys$UI$Bounds(x, y, width, height) {
x = Math.round(x);
y = Math.round(y);
var e = Function._validateParams(arguments, [
{ name: "x", type: Number, integer: true },
{ name: "y", type: Number, integer: true },
{ name: "width", type: Number, integer: true },
{ name: "height", type: Number, integer: true }
]);
if (e) throw e;
this.x = x;
this.y = y;
this.height = height;
this.width = width;
}
回答by Alex Z
I had a similar issue; resolved after following the solution posted here by nileshsaikhede http://forums.asp.net/t/1884400.aspx/1
我有一个类似的问题;按照 nileshsaikhede http://forums.asp.net/t/1884400.aspx/1在此处发布的解决方案后解决
All I had to do was add
我所要做的就是添加
<meta http-equiv="X-UA-Compatible" content="IE=7" />
to my master page.
到我的母版页。
回答by Hemendra Shah
I figure out the one option. I have modified the MicrosoftAjax.jsand MicrosoftAjax.debug.jsfile for rounding the point value before returning Sys.UI.Pointfor all areas - see as below.
我想出了一种选择。我已经修改了MicrosoftAjax.js和MicrosoftAjax.debug.js文件返回前四舍五入的点值Sys.UI.Point的各个领域-见下文。
if (typeof param1 === "number")
{
param1 = Math.round(param1);
}
if (typeof param2 === "number")
{
param2 = Math.round(param2);
}
return new Sys.UI.Point(param1, param2);
I have referenced modified js file using Script option in ScriptManager code of ASPX page. That's how it is done.
我在 ASPX 页面的 ScriptManager 代码中使用 Script 选项引用了修改后的 js 文件。就是这样完成的。
I hope it helps other.
我希望它可以帮助其他人。
回答by Vijay B Kale
if your using internet explorer then press ALTselect Tools -----> Compatibility View -------> then add your website to be displayed in Compatibility. hope it will help you.
如果您使用 Internet Explorer 然后按ALT选择工具 -----> 兼容性视图 -------> 然后添加您的网站以在兼容性中显示。希望它会帮助你。

