0
我不知道这一点:的Javascript:一个循环后打开URL给出了正确的答案
var right = {"Google" :1, "Bing" :1}
do {
var website = prompt("Where should I redirect you: Google, Yahoo!, ebay or CCSF?", "");
} while (!right[website]);
if (website == "Google") {
var url = "https://www.google.com/";
window.location(url, '_blank');
window.focus();
} else if (website == "Bing") {
var url = "http://www.bing.com/";
window.location(url, '_blank');
window.focus();
} else {
;
}
应该保持一个人,直到他在正确的字类型(谷歌或冰在我的例子中环)。但是,下一个功能打开此网址无法正常工作。 (我不想使用选择/选项)。另外,结束“其他”也看起来对我很可疑。
谢谢。
太好了!就是这么简单:)谢谢。它打开我一个新的窗口,而不是新的标签虽然... – Art 2013-02-27 00:53:17
尝试没有'_blank',但这也取决于浏览器设置 – 2013-02-27 00:55:58