How to go to website from list in JavaScript
Let's say I have a list such as
var websites = {
website1.com,
website2.com,
website3.com,
};
When I press something, such as a <a>
tag, choose from the list of websites, and automatically go there. I don't want any customization, repeating pages are fine, I just want something basic and simple.
You just need to make it a complete URL and set window.location
equal to that URL.
Also, for a simple list, an array like [1, 2, 3]
can be easier to work with than an object like {1,2,3}
. Try this:
var websites = [
"website1.com",
"website2.com",
"website3.com"
];
var exitURL = "http://" + websites[i];
window.location = exitURL;
链接地址: http://www.djcxy.com/p/42214.html
下一篇: 如何从JavaScript列表中访问网站