【问题标题】:jQuery fancybox loads iframe in less HTML page but not on WordpressjQuery fancybox 在较少的 HTML 页面中加载 iframe,但不在 Wordpress 上
【发布时间】:2012-09-16 15:26:55
【问题描述】:

我很难在 Wordpress 中找到不允许使用 fancybox 加载 iframe 的 jQuery 插件或其他内容。

带有剥离 html 的 Easy Fancybox 可以工作,以下是工作版本

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>

<!-- Add jQuery library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<link rel='stylesheet' id='easy-fancybox.css-css'  href='http://www.wp-responsive-themes.com/wp-content/plugins/easy-fancybox/easy-fancybox.css.php?ver=1.3.4' type='text/css' media='screen' />

<script type='text/javascript' src='http://www.wp-responsive-themes.com/wp-content/plugins/easy-fancybox/fancybox/jquery.fancybox-1.3.4.pack.js?ver=1.3.4'></script>
</head>
<body>
<a href="http://wp-responsive-themes.com/"  data-fancybox-type="iframe"  title="preview" class="preview fancybox-iframe">Preview</a>
<script type="text/javascript">
jQuery(document).ready(function() {
      $("a.preview").fancybox({
           'Width'    :       960 ,
           'Height'   :       640,
           'hideOnContentClick': false, 
           'type':'iframe'
      }); 
});

</script>
</body>
</html>

但 fancybox 无法在页面上加载 iframe (Wordpress)。

点击“iPhone 5 Vertical Orientation Preview”时应该打开 iframe 在下一页

http://www.wp-responsive-themes.com/2012/myapp-adaptive-wp-theme-for-app-developers-429/

需要帮助

亲切的问候

【问题讨论】:

  • 图片在同一个页面中使用fancybox而不是iframe加载

标签: jquery wordpress fancybox


【解决方案1】:

Wordpress 的设置方式是使用 jQuery 时不会发生冲突。这意味着 $ 不容易获得。

http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers

jQuery(document).ready(function($) {
      $("a.iphone4_vertical").fancybox({
           'Width'    :       960 ,
           'Height'   :       640,
           'hideOnContentClick': false, 
           'type':'iframe'
      }); 
});

添加$ 作为函数参数应该可以解决您的问题。

【讨论】:

  • @AnupRaj :还要确保 widthheight 没有大写字母(js 参数区分大小写)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-11
  • 1970-01-01
相关资源
最近更新 更多