Questions about using web hosting

I want to use it to move to a specific blog site at random. Is it possible?
I have attached an example code.

blog = new Array('', '' , '' );
r = Math.floor( Math.random() * blog.length);
location.href = blog[r];

It was used as a Google translator, so the content may be awkward.