<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <script language="javascript" type="text/javascript"> function Button1_onclick(){ var strName = "dann";//登錄的名字建議使用:域\名字 var strPWD = "user@2007";//登錄密碼 var location = 'http://danntest/Pages/Default.aspx'; //首頁 var auth = new ActiveXObject('msxml2.xmlhttp'); auth.open('post',location,false,strName,strPWD); auth.send(); switch(auth.status) {case 200:window.location.href = 'http://danntest/Pages/Default.aspx'; // 登錄頁面 break; case 401:alert('賬號或密碼錯誤!'); break; default:alert('抱歉,請再試一次!'); } } </script> </head> <body> <input id="Button1" onclick="Button1_onclick()" type="button" value="button" /> </body> </html>
轉自:http://www.cnblogs.com/tomz/p/3437493.htmljavascript