Why is IE7 and IE8 Giving me "Access Denied" when calling jQuery?

I am using the Google CDN to call the jQuery 1.4.2 Min File into my application. One FF, Chrome, Safari everything is working great. But for some reason, i get a "Access Denied" error for the jquery.min.js file on line 127...? I don't get it. Anyone have a clue why this is acting up in this way? I am totally clueless. ! Screenshot

Code

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
    type="text/javascript"></script>

.

case 1:
methodName = "SavePropertyInformation";
var HasFoundProperty, PropertyType, NumberOfUnits,
PropertyAddress, PropertyCity, PropertyState,
PropertyZipCode, PropertyCounty;

HasFoundProperty = $("#foundProperty input[type='radio']:checked").val();
PropertyType = $('#<%= this.fvApp.FindControl("ddlPropertyType").ClientID %>').val();
NumberOfUnits = $('#<%= this.fvApp.FindControl("ddlNumberOfUnits").ClientID %>').val();
PropertyAddress = $('#<%= this.fvApp.FindControl("txtPropertyAddress").ClientID %>').val();
PropertyCity = $('#<%= this.fvApp.FindControl("txtPropertyCity").ClientID %>').val();
PropertyState = $('#<%= this.fvApp.FindControl("ddlPropertyState").ClientID %>').val();
PropertyZipCode = $('#<%= this.fvApp.FindControl("txtPropertyZipCode").ClientID %>').val();
GetCountyFromZipCode(PropertyZipCode);
PropertyCounty = GetCounty();
data = "{WebAccessID:'" + WebAccessID + "', HasFoundProperty:'" + HasFoundProperty + "', PropertyType:'" + PropertyType + "', NumberOfUnits: '"
    + NumberOfUnits + "', PropertyAddress: '" + PropertyAddress + "', PropertyCity:'" + PropertyCity
    + "', PropertyState:'" + PropertyState + "', PropertyZipCode:'" + PropertyZipCode + "',PropertyCounty:'"
    + PropertyCounty + "' }";
doAjaxReq(methodName, data, showSavingDialog);
break;

Making a call to a sub domain is seen as a different domain because of the Same Origin policy. Make sure that you are setting document.domain to avoid access denied with the Same Origin policy.

To get the document.domain in sync you need to set it in two places. Add a script tag that set the domain, and you need to have an iframe on the page that sets the same thing on the other domain.

The page that the Ajax call is made from "www.example.com" and is calling "ajax.example.com":

<script type="text/javascript">
  document.domain = "example.com";
</script>
<iframe src="http://ajax.example.com/domainCode.html"></iframe>

The "domainCode.html" would just contain the script tag

<html>
  <head>
    <script type="text/javascript">
      document.domain = "example.com";
    </script>
  </head>
  <body>
  </body>
</html>

With that in place you should be able to talk between your sub domains.


Make sure IE doesn't have any proxy settings, auto config script, or anything like that in preferences. I see nothing wrong with your code.


I believe the problem stems from a certain security feature in Internet Explorer where you are not allowed to load code from a remote server unless its considered "trusted" by the browser. From what I read, there are instances where the browser does not complain about this, and then there are other situations where it won't allow it. Not sure what the specific trigger is in your instance, but I would bet that's the root of your problem here.

If I were you, I would just load the jQuery locally until you have performance issues that prompt you to do otherwise. Name the file jquery-latest.js, and then as new versions of JQ appear, test them locally first, and then replace the file when you're confident it works. OR, keep the version-named file and upgrade each page piecemeal, whichever's easier for your application use.

Source: http://geekswithblogs.net/TimH/archive/2006/05/17/78673.aspx

链接地址: http://www.djcxy.com/p/47332.html

上一篇: 线图像尺寸?

下一篇: 为什么IE7和IE8在调用jQuery时给我“访问被拒绝”?