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 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序