magnific popup:将整个html页面加载到弹出窗口中

时间:2014-01-07 13:57:16

标签: javascript jquery iframe magnific-popup

我想用弹出的插件在弹出窗口中加载一个完整的html页面。如果我尝试:

<a href='/page.html' class='btn' id="edit-images-btn">Edit images</a>
<script>
$('#edit-images-btn').magnificPopup({
    type: 'ajax'
});
</script>

它产生了这个:

enter image description here

这在图形上非常符合我的要求,但问题是<html></html>的内容直接插入到dom中,而不是放在保护性的iframe中。这不可能是好事。我想要大胆的弹出窗口为内容创建一个不可见的iframe。我在控制台中也遇到了一些奇怪的js错误:

Failed to load resource: the server responded with a status of 405 (Method Not Allowed) http://maps.googleapis.com/maps/api/js?key=AIzaSyBW_Py3pNsiSifVJzqL8J28LFCQ6P1KaX0&sensor=false&libraries=places&_=1389102487002
Failed to load resource: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8008' is therefore not allowed access. http://maps.googleapis.com/maps/api/js?key=AIzaSyBW_Py3pNsiSifVJzqL8J28LFCQ6P1KaX0&sensor=false&libraries=places&_=1389102487002
XMLHttpRequest cannot load http://maps.googleapis.com/maps/api/js?key=AIzaSyBW_Py3pNsiSifVJzqL8J28LFCQ6P1KaX0&sensor=false&libraries=places&_=1389102487002. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8008' is therefore not allowed access. 

这些错误可能是无效的html结构或谷歌地图api多次包含的结果。不确定。它可能会通过iframing内容来解决。

1 个答案:

答案 0 :(得分:2)

如果你想创建iframe,为什么不使用iframe类型的弹出窗口而不是ajax?

否则,如果您只想删除HTML和BODY标记,并且只保留BODY的内容,则可以在parseAjax回调http://dimsemenov.com/plugins/magnific-popup/documentation.html#ajax_type

中解析内容
相关问题