第一步:先做一个登录表单,将需要数据发送给JavaScript函数。
<form name=″mailForm″ action=″JavaScript:go()″ Onsubmit=″return check(this)″ method=″post″>
<p><select name=″mailSelect″ size=″1″>
<option selected value=″None″>选择邮箱</option>
<option value=″mail.sina.com.cn/cgi-bin/login;u;psw″>新浪</option>
<option value=″web.163.net/cgi/login;user;pass″>163</option>
<option value=″freemail.263.net/cgi/login;user;pass″>263</option>
<option value=″freemail.990.net/prog/login;user;pass″>990</option>
</select><br>
账号:<input type=″text″ name=″name″ size=″12″ onfocus=″this.select()″><br>
密码:<input type=″password″ name=″password″ size=″12″ onfocus=″this.select()″><br>
<input type=″submit″ value=″登录″ style=″font-size: 9pt″ name=″submit″>
<input type=″reset″ value=″重置″ name=″reset″ style=″font-size: 9pt″></p>
</form>
第二步:将下面代码放在登录表单所在页面的<head>……</head>之间。
<script language=″JavaScript″><!--
function makeURL(){ var objForm=document.mailForm;
var intIndex=objForm.mailSelect.options.selectedIndex;
var varInfo=objForm.mailSelect.options[intIndex].value;
var arrayInfo=varInfo.split(′;′);
var strName=objForm.name.value,varPasswd=objForm.password.value;
var strProvider=arrayInfo[0],strIdName=arrayInfo[1],varPassName=arrayInfo[2];
var strUrl=′http://′+strProvider+′?′+strIdName+′=′+strName+′&′+varPassName+′=′+varPasswd;
return strUrl;
}
function go(){
var strLocation=makeURL();
window.open(strLocation,′′,′′);
}
function check(input){
if(input.mailSelect.options.selectedIndex==0){
alert(″请选择你的邮箱!″);
return false;}
if(input.name.value==″″){
alert(″你忘了填写您的账号名了!″);
input.name.focus();
return false;}
if(input.password.value==″″ || input.password.value.length<3){
alert(″你的密码长度小于3字符吗?还是重新填写吧!″);
input.password.focus();
return false;}
else return true;
}
--></script>
<form name=″mailForm″ action=″JavaScript:go()″ Onsubmit=″return check(this)″ method=″post″>
<p><select name=″mailSelect″ size=″1″>
<option selected value=″None″>选择邮箱</option>
<option value=″mail.sina.com.cn/cgi-bin/login;u;psw″>新浪</option>
<option value=″web.163.net/cgi/login;user;pass″>163</option>
<option value=″freemail.263.net/cgi/login;user;pass″>263</option>
<option value=″freemail.990.net/prog/login;user;pass″>990</option>
</select><br>
账号:<input type=″text″ name=″name″ size=″12″ onfocus=″this.select()″><br>
密码:<input type=″password″ name=″password″ size=″12″ onfocus=″this.select()″><br>
<input type=″submit″ value=″登录″ style=″font-size: 9pt″ name=″submit″>
<input type=″reset″ value=″重置″ name=″reset″ style=″font-size: 9pt″></p>
</form>
第二步:将下面代码放在登录表单所在页面的<head>……</head>之间。
<script language=″JavaScript″><!--
function makeURL(){ var objForm=document.mailForm;
var intIndex=objForm.mailSelect.options.selectedIndex;
var varInfo=objForm.mailSelect.options[intIndex].value;
var arrayInfo=varInfo.split(′;′);
var strName=objForm.name.value,varPasswd=objForm.password.value;
var strProvider=arrayInfo[0],strIdName=arrayInfo[1],varPassName=arrayInfo[2];
var strUrl=′http://′+strProvider+′?′+strIdName+′=′+strName+′&′+varPassName+′=′+varPasswd;
return strUrl;
}
function go(){
var strLocation=makeURL();
window.open(strLocation,′′,′′);
}
function check(input){
if(input.mailSelect.options.selectedIndex==0){
alert(″请选择你的邮箱!″);
return false;}
if(input.name.value==″″){
alert(″你忘了填写您的账号名了!″);
input.name.focus();
return false;}
if(input.password.value==″″ || input.password.value.length<3){
alert(″你的密码长度小于3字符吗?还是重新填写吧!″);
input.password.focus();
return false;}
else return true;
}
--></script>