Jump to content

Alternating Images With Links.


novartic
 Share

Recommended Posts

Hia chaps.Looked into this a few months back with my own site though with no luck.Did a search today as I need to get it working >.<What I am after is the following:Load the home page or what ever, and your add shows, along with a hyperlink for the user to do a clicky.If the user then refreshes the page or goe's to another page, the add will automatic show another add in the same location along with a link etc..I found this which was very interesting, though I cant get it working with my gifs or for that matter get it working at all inc the hyperlinks.

 <script type="text/javascript">//<![CDATA[var theImages = [{  url: "images/Companys/Maxpower_Nissan.gif" // <jsp:forward page="http://www.google.com" />},{  url: "images/Companys/banner_120x600.gif"},];var randomNumber;var previouslyUsedRandomNumbers = "";for(var i = 1; i <= 1; i++){    do    {        randomNumber = Math.floor(Math.random() * theImages.length);    }    while(previouslyUsedRandomNumbers.indexOf("|" + randomNumber + "|") >= 0);    previouslyUsedRandomNumbers += "|" + randomNumber + "|";    document.getElementById("i" + i).src= theImages[randomNumber].url;    }//]]></script>

Please advice :)

Link to comment
Share on other sites

I did this before once and I used a php random insert script.... I don't recall exactly what the code was, but try looking into that.

Link to comment
Share on other sites

In this code:

var theImages = [{  url: "images/Companys/Maxpower_Nissan.gif" // <jsp:forward page="http://www.google.com" />},{  url: "images/Companys/banner_120x600.gif"},];

There's an extra comma at the end that is going to cause a problem.This line is completely pointless:for(var i = 1; i <= 1; i++)I assume that originally there was more than one ad placeholder.

Link to comment
Share on other sites

I prefer to use hidden inputs and random names instead of a captcha. You can have a form like this:

<input type="text" name="subject" style="display: none;"><input type="text" name="comments" style="display: none;"><input type="text" name="message" style="display: none;">Subject: <input type="text" name="dj38s2j9"><br>Message: <input type="text" name="k39d84j5"><br><input type="submit">

Once that gets submitted, you check if the "subject", "comments", or "message" fields were filled out. If they were filled out, then it's probably a spam bot. Otherwise, you use the other two random name fields for your data.

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...