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