-1

这是在 jquery 函数中使用 php 脚本的正确方法吗?pathToTabImage 变量

<script type="text/javascript">
    $(function(){
        $('.slide-out-div').tabSlideOut({
            tabHandle: '.handle',                     //class of the element that will become your tab
            pathToTabImage: '<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/images/ack.jpg';, //path to the image for the tab //Optionally can be set using css
            alert(pathToTabImage);
            imageHeight: '122px',                     //height of tab image           //Optionally can be set using css
            imageWidth: '125px',                       //width of tab image            //Optionally can be set using css
            tabLocation: 'right',                      //side of screen where tab lives, top, right, bottom, or left
            speed: 600,                               //speed of animation
            action: 'click',                          //options: 'click' or 'hover', action to trigger animation
            topPos: '600px',                          //position from the top/ use if tabLocation is left or right
            leftPos: '550px',                          //position from left/ use if tabLocation is bottom or top
            fixedPosition: false                      //options: true makes it stick(fixed position) on scroll
        });

    });
4

2 回答 2

0

删除分号。

/images/ack.jpg';,

/images/ack.jpg',

此外,这alert对你也没有任何好处,需要去。

alert(pathToTabImage);

于 2012-06-18T04:51:59.307 回答
-1

它是注入 PHP 代码的可用方法之一,以 HTML、CSS 或 JS 文档/片段的形式注入。但是,从语法上讲,几乎没有错误。

PHP 错误

<?php echo $this->baseurl ?>

结束语句上没有分号

JavaScript 错误

pathToTabImage: '...';, //...

不需要的分号,以不正确的方式结束语句

alert(pathToTabImage);

在另一个语句中注入一个独立语句

于 2012-06-18T05:37:07.850 回答