javascript - 放大弹出窗口 : load whole html page into a popup

标签 javascript jquery iframe magnific-popup

我想使用 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 结构或多次包含 google map API 造成的。没有把握。可能可以通过对内容进行 iframe 来解决。

最佳答案

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

否则,如果你只是想去掉 HTML 和 BODY 标签,只保留 BODY 的内容,你可以在 parseAjax 回调 http://dimsemenov.com/plugins/magnific-popup/documentation.html#ajax_type 中解析内容。

关于javascript - 放大弹出窗口 : load whole html page into a popup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20973486/

相关文章:

javascript - 在 beforeunload 事件处理程序中停止页面卸载

jquery - jQuery : IE11 AJAX error handler not giving error information

jquery - jquery的empty()方法会清除通过非jquery方式创建的事件监听器吗

javascript - 从 iframe 关闭父弹出窗口

javascript - 是 document.write 阻塞

javascript - 如何让程序员在 JavaScript 中实现正确的回调?

java - selenium 找不到出现在我的浏览器中的 iframe

php - 我可以根据url更改iframe src吗?

javascript - 如何在具有多个嵌套元素的 div 上伪造省略号?

javascript - Internet Explorer 中的 jQuery UI 对话框和 maxHeight