0
<link rel="stylesheet" href="<?php echo $this->getSkinUrl(''); ?>js/fancybox/source/jquery.fancybox.css?v=2.0.6" type="text/css" media="screen" />
<script type="text/javascript" src="<?php echo $this->getSkinUrl(''); ?>js/fancybox/source/jquery.fancybox.pack.js?v=2.0.6"></script>

<script type="text/javascript">

$(document).ready(function() {
  $("a#image").fancybox();
  $("a#image").trigger('click');
  $("a#image").hide();
});

<a id="image" href="banner-about-cart.png"><img src="<?php echo $this->getSkinUrl() ?>images/banner-about-cart.png" alt=""/></a>

有任何想法吗?我在没有花哨的插件的情况下测试的图像加载我可以在站点中看到图像,我也在使用 magento。

4

3 回答 3

1

我认为你应该指定内联的fancybox类,记住css文件中也有样式代码:

 <a id="image" href="banner-about-cart.png" class="fancybox">
    <img src="<?php echo $this->getSkinUrl(); ?>images/banner-about-cart.png" alt="" />
 </a>
 <!--notice that you forgot to semi-colon after $this->getSkinUrl() -->
<script>
   $(document).ready(function() {
     $("a#image").fancybox();
     //try wrapping the rest of the code in this document load:
     $(document).load(function(){
         $("a#image").trigger('click');
         $("a#image").hide();
     });
   });
</script>

另外,如果您尝试以下方法之一,会发生什么?:

 $('#image').trigger('click');
//or
$('a[id="image"]').trigger('click');
//?
于 2012-07-05T09:49:01.263 回答
0

也许这

href="banner-about-cart.png"

应该

href="<?php echo $this->getSkinUrl() ?>images/banner-about-cart.png"

或者干脆

href="images/banner-about-cart.png"

检查您是否有正确的路径。如果禁用了javascript(并且链接尚未隐藏),您可以链接到图像吗?

旁注

这个 :

  $("a#image").fancybox();
  $("a#image").trigger('click');
  $("a#image").hide();

可以简化为:

$("a#image").fancybox().trigger('click').hide();

... 纯娱乐 ;)

于 2012-06-01T22:37:32.107 回答
0

使用时,getSkinUrl()您应该将路径作为函数的参数,而不是在它之后。该方法中有逻辑在当前主题中查找您指定的文件,如果那里不存在,则返回到默认主题路径。

例子

假设您使用自定义主题(名为 custom/theme)。给定以下文件结构:

skin/
  frontend/
    custom/
      theme/
        images/
          new-logo.png
    default/
      default/
        images/
          new-logo.png
          logo.png

// Good!
<?php echo $this->getSkinUrl('images/new-logo.png'); ?>
// returns http://www.example.com/skin/frontend/custom/theme/images/new-logo.png

// Good, even though images/logo.png doesn't exist in our custom theme.
<?php echo $this->getSkinUrl('images/logo.png'); ?>
// returns http://www.example.com/skin/frontend/default/default/images/logo.png

// Bad! This will cause a 404 error!
<?php echo $this->getSkinUrl('') . 'images/logo.png'; ?>
// returns http://www.example.com/skin/frontend/custom/theme/images/logo.png

我应该指出,我认为这不适用于查询字符串?v=2.0.6因此您需要附加:

<link rel="stylesheet"
      href="<?php echo $this->getSkinUrl('js/fancybox/source/jquery.fancybox.css'); ?>?v=2.0.6"
      type="text/css"
      media="screen" />
于 2012-06-01T22:58:46.407 回答