【问题标题】:magnific popup: load whole html page into a popupmagnific popup:将整个 html 页面加载到弹出窗口中
【发布时间】:2014-01-07 13:57:16
【问题描述】:

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

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

它产生这个:

这在图形上是我想要的,但问题是&lt;html&gt;&lt;/html&gt; 的内容直接插入到 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 maps api 造成的。不确定。它可能会通过 iframe 内容来解决。

【问题讨论】:

标签: javascript jquery iframe magnific-popup


【解决方案1】:

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

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

【讨论】:

  • 是的,我发现:pattern: { index: '', src: '%id%' } 用于 iframe 模式。效果很好。我需要使 iframe 透明,但我想我会管理的。谢谢!
  • 哈,即使没有这种模式也能正常工作。我想这是默认行为。酷。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多