.load() works in IE and dreamweaver preview, but no opera and chrome

我只是一个虾纸丫 提交于 2019-12-13 04:46:51

问题


Cant get this code to work in chrome, which is essential since I'm developing for android. Can anyone see the error?

I just want to load 'page1.html' into '#container1'. Should be easy and it was working before. But I have tried rebuilding the code from scratch and I can't see what the error is.

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>TheTutorialBlog.com : jQuery Deep Linking</title>    

  <link href="css_elIndex.css" rel="stylesheet" type="text/css" />
<script src="jquery-1.7.2.min.js"></script>
<script src="bbq-1.2.js"></script>
<script type="text/javascript">

$("document").ready(function(){
    alert('doc ready');
    $('#container1').load('page1.html');
});
</script>
</head>
<body>
<div class ="topBar">
    <div class = "backButton">Home</div>
</div>
<div id="pageContainer">
    <div class="pageViewer" id="container1">            
    </div>
    <div class="pageViewer" id="container2"> 
    </div>
    <div class="pageViewer" id="container3"> 
    </div>
</div>

</body>
</html>

Page1.html:

<ul class="tabs">
    HEi
</ul>

回答1:


When accessing files via the local file system (file:// URLs) you cannot load any local AJAX resources in Chrome and Opera for security reasons.

When using HTTP there is the "same origin policy" to prevent sites from accessing data they shouldn't have access to. However, on the local file system there is no way to know what's safe to access and what not. So AJAX requests to local files are generally blocked.



来源:https://stackoverflow.com/questions/11281769/load-works-in-ie-and-dreamweaver-preview-but-no-opera-and-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!