dimanche 22 février 2015

How do I open a random website in javascript?


var links = new Array();
links[0] = "http://www.google.com/";
links[1] = "http://www.bing.com/";
links[2] = "http://www.yahoo.com/";
links[3] = "http://www.apple.com/";

function openLink() {
var i = Math.floor(Math.random() * links.length);
parent.location = links[i];
return false;
}

chrome.browserAction.onClicked.addListener(function(tab) {
var action_url = "http://google.com";
chrome.tabs.update(tab.id, {url: action_url});
});


As of right now I can only open Google, I want to be able to open a random link from my array. How can I complete this from here?





Aucun commentaire:

Enregistrer un commentaire