Jump to content

Random URL Redirect help !


kareem_elzeiny

Recommended Posts

Hello,In brief I'm using this Script whenever a visitor click an external link on my blog

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'/><script type='text/javascript'>//<![CDATA[jQuery('a').each(function() {// Let's make external links open in a new window.var href = jQuery(this).attr('href');if (typeof href != 'undefined' && href != "" && (href.indexOf('http://') != -1 || href.indexOf('https://') != -1) && href.indexOf(window.location.hostname) == -1) {   $(this).attr("target", "_blank");   if (href.search(/(bit.ly|google.com)/) == -1) {	  $(this).attr('href', "http://dstats.net/download/"+"?link="+href+"&");   }  }});//]]></script>

I need to add a random URL from a given list before the href ("http://www.url1.com/", "http://www.url2.com/", "http://www.url3.com/")

	  $(this).attr('href', "http://dstats.net/download/"+"RANDOM URL FROM THE LIST"+"?link="+href+"&");

Any Ideas ??Regards,,

Link to comment
Share on other sites

Try this:

var urls = ["http://www.url1.com/", "http://www.url2.com/", "http://www.url3.com/"];var key = Math.floor(Math.random()*urls.length);var url = urls[key];$(this).attr('href', "http://dstats.net/download/"+url+"?link="+href+"&");

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...