URL重定向Javascript? 我试图用http://重定向输入的网址,然后提示,直到找到http://,如果找到它,它会将它引导到输入的网站。URL重定向Javascript
继承人到目前为止我的代码:
function enter() {
var keepGoing = true;
var email;
while (keepGoing) {
keepGoing = false
email = prompt("Please Enter Website Address");
// Website Address validation to see if it has http://
if (email.indexOf('http://') === -1) {
alert("Not valid Web Address");
keepGoing = true;
}
// if nothing was entered
else if (email == '') {
var email = prompt("Please Enter Valid Web Address");
}
}
}
备注:'keepGoing'变量是不必要的。 – JJJ 2013-03-09 07:28:08
'email.indexOf('http://')=== -1'应该是'email.indexOf('http://')!= 0',因为你必须验证http://是第一部分的网站地址 – 2013-03-09 07:33:04