2017-02-12 64 views
1

我想使用jBox(Stephan Wagner),但我无法让我的模态窗口显示一个网页。任何人都可以看到我出错的地方。jBox不返回内容

$(document).ready(function() { 

new jBox('Modal', { 
width: 900, 
height: 550, 
url: 'http://www.google.com', 
}, 
reload: 'strict' 
}).open(); 

}); 

非常感谢您的时间。

回答

1

查看Ajax选项,当你在Ajax对象使用你的代码应该只是罚款:https://stephanwagner.me/jBox/options#ajax

而且,你只能使用具备访问控制首集的网页,看看这个拨弄更新代码:https://jsfiddle.net/StephanWagner/7hh5a6oc/

new jBox('Modal', { 
    width: 900, 
    height: 550, 
    ajax: { 
    url: '//www.google.com', 
    reload: 'strict' 
    } 
}).open(); 

跟随误差上来了:"XMLHttpRequest cannot load https://www.google.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://fiddle.jshell.net' is therefore not allowed access."

所以基本上,网页不喜欢被来源不明的加载。它被允许时,您可以随时加载通过AJAX的内容,请参见本拨弄它采用ajaxresponse.com:https://jsfiddle.net/StephanWagner/569y8wcp/

您也可以尝试使用iframe,也看到这个小提琴有关:https://jsfiddle.net/StephanWagner/569y8wcp/2/(我们添加一个iframe与网页的一次jBox被创建)。但同样,它只适用于网页允许从外部来源加载(如我的网页:https://jsfiddle.net/StephanWagner/569y8wcp/3/

+0

嗨有没有办法让你的示例代码在“https://jsfiddle.net/StephanWagner/569y8wcp/ 3 /“点击链接时触发。再次,非常感谢您的帮助。我正在学。 – DCJones

+0

全部排序,谢谢 – DCJones