Body: Ajax.net 1.0 Official version has been released for a long time , I encountered cross-origin access problems during my first attempt. , The error message is displayed when you click the left mouse button at any position on the page. : "Access Is denied ", Searched , Solution found .
1. x :\ Program Files \ Microsoft ASP. net \ ASP. NET 2.0 Ajax extensions \ v1.0.61025 \ system in microsoftajaxlibrary. web. copy the extensions folder to the project. .
2.Open System. Web. Extensions\ Microsoftajax. JsFile,Locate the case SYS. browser. internetexplorer Section,Replace the content with the followingCode:
Switch (SYS. browser. Agent ){ Case SYS. browser. internetexplorer: SYS. UI. domelement. getlocation = Function (){If (. 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 =. 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 ;
Note that the above Code should be written in one line.
3.Open System. Web. Extensions\ Microsoftajax.Debug. JS,Locate the case SYS. browser. internetexplorer Section,Replace the content with the following code::
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.IsScriptmanagerAddScriptreference,Reference the modifiedJSFile:
<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>
ReferenceArticle-1:Http://blog.darkthread.net/blogs/darkthreadtw/archive/2007/04/13/kb-cross-domain-access-denied-issue-of-asp-net-ajax-page.aspx
References-2:Http://weblogs.asp.net/bleroy/archive/2007/01/31/how-to-work-around-the-quot-access-denied-quot-cross-domain-frame-issue-in-asp-net-ajax-1-0.aspx
[Solution to cross-origin access error from ajax.net 1.0]
Category: JS/html/CSS/XML
Release date: