2014-02-14 45 views
4

我有bootstrap模式数据远程工作的所有浏览器除了铬。背景显示,但不是模式本身。引导模式数据 - 远程在Chrome中不工作

parentPage.html

<a href="#" data-toggle="modal" data-target="#myModal"><img src="images/ball.gif" alt="Add Account"/></a> 
<div class="modal fade" id="myModal" tabindex="-1" data-remote="./popups/remotePage.html" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" > 
</div> 

remotePage.html

<div class="modal-dialog"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
     Header 
     </div> 
     <div class="modal-body"> 
      One fine body... 
     </div> 
     <div class="modal-footer">Footer 
     </div> 
    </div><!-- /.modal-content --> 
    </div><!-- /.modal-dialog --> 

我已经尝试在<a>标签将数据远程。

我在想什么?

回答

8

请改用此代码。假设你正在使用Twitter的引导3

parentPage.html

<a href="./popups/remotePage.html" data-toggle="modal" data-target="#myModal"><img src="images/ball.gif" alt="Add Account"/></a> 
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" > 
<div class="modal-dialog"> 
    <div class="modal-content"> 
    </div> 
</div> 
</div> 

remotePage.html

<div class="modal-header">Header</div> 
<div class="modal-body"> 
    One fine body... 
</div> 
<div class="modal-footer">Footer</div> 

而且不要忘记,目录结构是这样的:

parentPage.html 
popups 
    remotePage.html 

更新

根据对答案的评论,谷歌Chrome不允许从文件协议(file://)作为安全措施的XMLHttpRequest。你有两个选项可用。

一个是你的文件托管在HTTP服务器。如果您使用的是Windows,请使用WAMP或XAMPP。

而第二个选项是关闭Chrome Web安全模式,但不建议这样做

chrome.exe --disable-web-security 

供您参考:Allow Google Chrome to use XMLHttpRequest to load a URL from a local file

+0

是我使用Twitter的引导3,我仍然得到同样的结果。在FF中运行良好,但在Chrome中运行得不错。 – user3311026

+0

在parentPage.html的代码上做了一个小小的编辑。另外,按Ctrl + Shift + I查看Google Chrome的Web Developer工具,看看Javascript中是否有错误。 –

+0

你是对的错误! – user3311026