.load()在IE和Dreamweaver预览版中有效,但没有Opera和Chrome [英] .load() works in IE and dreamweaver preview, but no opera and chrome

查看:133
本文介绍了.load()在IE和Dreamweaver预览版中有效,但没有Opera和Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不能让此代码在chrome中工作,这是必不可少的,因为我正在为android开发.谁能看到错误?

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

我只想将'page1.html'加载到'#container1'中.应该很容易,并且以前可以正常工作.但是我尝试从头开始重建代码,但看不到错误所在.

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:

Page1.html:

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

推荐答案

通过本地文件系统(file:// URL)访问文件时,出于安全原因,您无法在Chrome和Opera中加载任何本地AJAX资源.

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

使用HTTP时,存在相同来源策略"以防止站点访问他们不应该访问的数据.但是,在本地文件系统上,无法知道什么是安全的,什么不是安全的.因此,通常会阻止对本地文件的AJAX请求.

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.

这篇关于.load()在IE和Dreamweaver预览版中有效,但没有Opera和Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆