Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Help with random ad positions

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36161
    gouc89
    Member

    I used the jquery code here (https://css-tricks.com/random-ad-positions/) but when I try to link the images, the link doesn’t follow the image; it stays at the original spot it was linked on the page. So it basically links the wrong image. Someone please help me, I’m desperate right now.

    #94870
    gouc89
    Member

    Messed up. See below.

    #94871
    gouc89
    Member

    You can see my page in action here: http://www.bluegrasscostsavers.com/html-testing.html

    Here’s my jq code:

    (function($){

    $.fn.shuffle = function() {

    var allElems = this.get(),
    getRandom = function(max) {
    return Math.floor(Math.random() * max);
    },
    shuffled = $.map(allElems, function(){
    var random = getRandom(allElems.length),
    randEl = $(allElems[random]).clone(true)[0];
    allElems.splice(random, 1);
    return randEl;
    });

    this.each(function(i){
    $(this).replaceWith($(shuffled));
    });

    return $(shuffled);

    };

    })(jQuery);

    $(function() {

    $("#ad-group-one img").shuffle();

    });

    _________________________________________________________________

    Here’s my HTML code:




    Seriously, I have to have this fixed ASAP and I really need some help, if anyone has any help for me or knows another way to successfully randomize images w/ link let me know!!!!!!

    #95022
    gouc89
    Member

    Bump. Still desperately need help :

    #95023
    TheDoc
    Member

    Why don’t you try using the PHP method? For me, it’s much better (and the only one I can help you with because I am useless when it comes to jQuery).

    #95024
    gouc89
    Member

    How can I do it on a site that has to end in .html? Can I create a separate PHP file and call it through the .html page? Sorry, I probably sound pretty clueless…

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Other’ is closed to new topics and replies.