1.将X:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\MicrosoftAjaxLibrary中的System.Web.Extensions文件夹复制到添加到项目中.
2.打开System.Web.Extensions\MicrosoftAjax.js文件,在其中找到case Sys.Browser.InternetExplorer节,将其内容替换为下面的代码:
switch(Sys.Browser.agent){case Sys.Browser.InternetExplorer:Sys.UI.DomElement.getLocation=function(a){if(a.self||a.nodeType===9)return new Sys.UI.Point(0,0);var b=a.getBoundingClientRect();if(!b)return new Sys.UI.Point(0,0);var c=a.document.documentElement,d=b.left-2+c.scrollLeft,e=b.top-2+c.scrollTop;try{var g=a.ownerDocument.parentWindow.frameElement||null;if(g){var f=2-(g.frameBorder||1)*2;d+=f;e+=f}}catch(h){}return new Sys.UI.Point(d,e)};break;
注意以上代码要写在一行中.
3.打开System.Web.Extensions\MicrosoftAjax.debug.js,在其中找到case Sys.Browser.InternetExplorer节,将其内容替换为下面的代码:
Sys.UI.DomElement.getLocation = function(element) {
if (element.self || element.nodeType === 9) return new Sys.UI.Point(0,0);
var clientRect = element.getBoundingClientRect();
if (!clientRect) {
return new Sys.UI.Point(0,0);
}
var ownerDocument = element.document.documentElement;
var offsetX = clientRect.left - 2 + ownerDocument.scrollLeft,
offsetY = clientRect.top - 2 + ownerDocument.scrollTop;
try {
var f = element.ownerDocument.parentWindow.frameElement || null;
if (f) {
var offset = 2 - (f.frameBorder || 1) * 2;
offsetX += offset;
offsetY += offset;
}
}
catch(ex) {
}
return new Sys.UI.Point(offsetX, offsetY);
}
break;
4.为ScriptManager添加ScriptReference,引用到我们修改过的js文件上:
<asp:ScriptManager ID="ScriptManager1" runat="server"><Scripts>
<asp:ScriptReference
Name="MicrosoftAjax.js" ScriptMode="Auto"
Path="~/[WebAppPath]/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js"/>
</Scripts></asp:ScriptManager>