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
    Feb 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening random url in new window

    I am using the following script
    <script>
    var randomurls=new Array()
    randomurls[0]="http://xxx1.com"
    randomurls[1]="http://xxx2.com"
    randomurls[2]="http://xxx3.com"
    randomurls[3]="http://xxx4.com"
    randomurls[4]="http://xxx.com"

    function randomurl(){
    window.location=randomurls[Math.floor(Math.random()*randomurls.length)]
    }
    </script>
    and when I click on the link below it takes me to one othe links above
    <a href="javascript:randomurl()" >Link</a>
    I want to be able to open this link in a new window but target=_blank does not work does anyone have any ideas
    thanks

  • #2
    New Coder
    Join Date
    Jan 2003
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    window.open(randomurls[Math.floor(Math.random()*randomurls.length)]);

  • #3
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks, I did try window.open but in the wrong place.


  •  

    Posting Permissions

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