0

我正在尝试让 fancybox 打开一个 php 文件;该文件包含此代码<?php echo "hi"; ?>。现在,当我将图像 href 属性设置为 jpeg 文件时,它可以正常加载。但是当我将它设置为一个 php 文件时,它不会加载。我可以帮助尝试让它加载一个 php 文件吗?

<a class= "fancyimg" href="http://mydomain.com/jquery.fancybox-1.3.4/count.php" ><img src="http://mydomain.com/jquery.fancybox-1.3.4/fancyimg2.jpg">

这是我的代码的一部分

       <script type="text/javascript">
    $(document).ready(function() {

        $(".fancyimg").fancybox({
            'overlayShow'   : false,
            'transitionIn'  : 'elastic',
            'transitionOut' : 'elastic'
        });
    });
</script>
4

2 回答 2

3

使用下面的 fancybox 的 type 属性打开 php 文件。

$(".fancyimg").fancybox({
 'width'        : '75%',
 'height'       : '75%',
 'autoScale'        : false, 
 'type'         : 'iframe',
 'overlayShow'   : false,
 'transitionIn'  : 'elastic',
 'transitionOut' : 'elastic'
});
于 2012-07-21T10:23:59.090 回答
1

你可以使用这样的东西:

$(".fancyimg").click(function() {
    $.fancybox.open({
        href : $(this).attr("data-id"),
        type : 'iframe',
        padding : 5
    });
});

而不是 href="http://mydomain.com/jquery.fancybox-1.3.4/count.php" 将您的链接放在一个名为 data-id 的自定义属性中,如下所示:

<a class= "fancyimg" href="#" data-id="http://mydomain.com/jquery.fancybox-1.3.4/count.php" ><img src="http://mydomain.com/jquery.fancybox-1.3.4/fancyimg2.jpg"></a>
于 2012-07-21T10:27:21.440 回答