Skip to content
Advertisement

How do I open up a random url from a list of url’s in a new time each time it is clicked?

I have some code that’ll allow me to open up a random website from a list of websites but I’d like to open each one up in a new tab, how do I do this?

Information you may need

the code

JavaScript

I tried doing the action in question at two different points and hope you’re input can help to correct this.

Location 1

JavaScript

Location 2

JavaScript

The following web address is what the code currently looks like and does.

*EDIT : The only changes I made are the websites.They’re much more on the live demo.

Advertisement

Answer

The code you wrote is wrong, since you change the address of the current window (via the line window.location=..., and other issues… but here:

Working example fiddle

Very similar, and works.

Code

HTML

JavaScript

JS

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement