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
    Regular Coder
    Join Date
    Jan 2003
    Location
    West Virginia
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random mp3 in new browser window?

    I took a standard "random link" js and substituted the addresses for some mp3's, and it works fine. However I'd like to have each random mp3 audio file open in a new browser window, so was wondering what I needed to change (or add) in the script below to make that happen??
    Code:
    <head>
    <SCRIPT LANGUAGE="JavaScript">
                  var linkarr=new Array()
                          linkarr[0]="http://www.DOMAIN-NAME.com/randomaudio/1.mp3"
                          linkarr[1]="http://www.DOMAIN-NAME.com/randomaudio/2.mp3"
                          linkarr[2]="http://www.DOMAIN-NAME.com/randomaudio/3.mp3"
                          linkarr[3]="http://www.DOMAIN-NAME.com/randomaudio/4.mp3"
                          linkarr[4]="http://www.DOMAIN-NAME.com/randomaudio/5.mp3"
                  function Getlink()
                   {
                    len=linkarr.length // how many entries in the array
                    randnm=Math.round(Math.random()*(len-1))
                    location.href=linkarr[randnm]
                  }
    </SCRIPT>
    </head>
    	 
    <body>
    <FORM><INPUT TYPE="button" VALUE="Random Poem" onClick="Getlink()"></FORM>
    </body>
    Thanks for any advice...

    .
    Reno CF

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    location.href=linkarr[randnm]

    needs to be

    var newWin = window.open(linkarr[randnm]);

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Location
    West Virginia
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That works perfectly Eric -- thanks very much...
    Reno CF


  •  

    Posting Permissions

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