How would you integrate the following? It would be great if the random URL would open in a new window. function randomlink(){ window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)] } function open_win(url_add) { window.open(url_add,'welcome', 'width=300,height=200,menubar=yes,status=yes, location=yes,toolbar=yes,scrollbars=yes'); } Code (markup):
like this: <html> <head> <script type="text/javascript"> var randomlinks=["http://www.google.com", "http://www.yahoo.com", "http://www.aol.com"]; var url_add=randomlinks[Math.floor(Math.random()*randomlinks.length)]; function open_win() { url_add=randomlinks[Math.floor(Math.random()*randomlinks.length)]; window.open(url_add); } </script> </head> <body> <input type="button" value=" Open a random link in a new window " onclick="open_win()" /> <h2>google</h2> <h2>yahoo</h2> <h2>aol</h2> </body> </html> Code (markup):