Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript question.

    Hey guys!
    I use this script on my site for banners and pics to rotating:

    <script language="JavaScript">
    <!--
    /*
    Random Image Link Script- By Website Abstraction(http://www.wsabstract.com)
    Over 200+ free JavaScripts here!
    Updated: 00/04/25
    */
    function random_imglink(){
    var myimages=new Array()
    //specify random images below. You can have as many as you wish
    myimages[1]="http://www.yoursite.com/pics/pic.jpg"
    myimages[2]="http://www.yoursite.com/pics/pic.jpg"
    myimages[3]="http://www.yoursite.com/pics/pic.jpg"
    //specify corresponding links below
    var imagelinks=new Array()
    imagelinks[1]="http://www.yoursite.com"
    imagelinks[2]="http://www.yoursite.com"
    imagelinks[3]="http://www.yoursite.com"
    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
    }
    random_imglink()
    //-->
    </script>
    The only problem is, I want all the sites to open in a new window..
    I try to ad an "blank" code in the html codes but then all my links in the site opens in a new window.. I want only the urls in this rotating code to open..

    How?

    Thanks in advance!

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    e.g.
    Code:
    <script type="text/javascript">
    
    	function random_imglink() {
    
    		var myimages = new Array();
    		myimages[1] = "http://www.yoursite1.com/pics/pic.jpg";
    		myimages[2] = "http://www.yoursite2.com/pics/pic.jpg";
    		myimages[3] = "http://www.yoursite3.com/pics/pic.jpg";
    
    		deadwood = myimages.splice(0,1); // remove the [0] index element from this array
    
    		var imagelinks = new Array();
    		imagelinks[1] = "http://www.yoursite1.com";
    		imagelinks[2] = "http://www.yoursite2.com";
    		imagelinks[3] = "http://www.yoursite3.com";
    
    		deadwood = imagelinks.splice(0,1); // remove the [0] index element from this array
    
    		var ry = Math.floor(Math.random()*myimages.length);
    
    		document.write("<a href=\""+imagelinks[ry]+"\" target=\"_blank\"><img src=\""+myimages[ry]+"\" border=\"0\"></a>");
    
    	}
    
    	random_imglink();
    
    </script>
    HTH

  • #3
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Aaaaah, excellent...

    Thanks!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •