开发者

Jquery thickbox url stripping

开发者 https://www.devze.com 2023-02-06 12:40 出处:网络
I am using jquery thickbox to show images and it works just fine but I am trying to add a click counter to update the database and when I add it, it makes thickbox not work and I am wondering if there

I am using jquery thickbox to show images and it works just fine but I am trying to add a click counter to update the database and when I add it, it makes thickbox not work and I am wondering if there is a way to strip the first part of the url

when I add in the click counter using php the links look like this

ttp://example.com/include/media_counter.php?url=http://example.com/image.jpg

Is there a way to make thick box strip ttp://example.com/include/media_counter.php?url= from the url and only use picture link? I want to be able to use both options "click counter and thickbox".

here is what my php looks like with the media counter and thick box will open but show no picture.

echo '<div class="images"><a href="'.$link_click.''.$row['media'].'"class="thickbox"><img src="'.$row['开发者_高级运维im_t_link'].'" height="100px" width="133px" title="'.$row[im_title].'"></a></div>';

if I remove $link_click it will work fine like this.

    echo '<div class="images"><a href="''.$row['media'].'"class="thickbox"><img src="'.$row['im_t_link'].'" height="100px" width="133px" title="'.$row[im_title].'"></a></div>';

any idea what I can do to resolve this? I am not good with javascript and such so I am looking for some help from people that do. Thanks.

Sorry I have the H taken from hyperlinks, Since I am a new user it only allows me one on here.


This should do it, counter via AJAX and href "rewrite" for Thickbox — place this in the head of your HTML file and given that you have jQuery and the thickbox plugin included, that should do:

<script type="text/javascript" charset="utf-8">
    $(function(){
        $('a.thickbox').each(function() {
            var $self = $(this),
                origHREF = this.href;

            $self
                .data('origHREF', origHREF)
                .attr('href', origHREF.split('?url=')[1])
                .click(function() {
                    $.get($(this).data('origHREF'));
                });
        });
    });
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消