dongmangsha7354 2013-06-21 12:05
浏览 32

PHP和Javascript中的字符串

I am trying to use a Jquery script called 'fancybox'

I need it so the title will be a link to a selected page, the link needs to include the user and the image name. I can these by PHP $_GET & a Javascript function.

The problem is including them both together as one string if you like. Instead of executing the javascript to return the image name, instead it just displays the code itself.

My question is how do I execute the javascript to include in the link whilst using the PHP still? (it worked before I included the PHP part)

This is what I got so far:

  jQuery(document).ready(function(){
        var imagename = function( item ) {
                        return item.href.replace('/images/<?php echo $_GET['user']; ?>/', '');
                    } 
    $(".fancybox")
        .attr('rel', 'gallery')
        .fancybox({

            margin      : 20,
            padding     : 10,
            openEffect  : 'none',
            closeEffect : 'none',
            nextEffect  : 'none',
            prevEffect  : 'none',
            margin      : [20, 60, 20, 60], // Increase left/right margin
            showCloseButton : true,
            showNavArrows   : true,
            title       : '<a href="delete.php?boat=<?php echo $_GET['user'].'&image='; ?>'+imagename+'">Delete this image?</a>'
        });
    })

This is the link it produces:

http://xxx.xxx.xxx.xxx/delete.php?boat=BoatCV20&image=function%20(%20item%20)%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20item.href.replace('/images/username1/',%20'');%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}

Thanks.

  • 写回答

5条回答 默认 最新

  • douchu2823 2013-06-21 12:10
    关注

    imagename it is a function, so you should call it imagename()

    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug