【旧版2016.4.17前】东北大学校园网一键登陆ajax版

来源:互联网 发布:js的json字符串转数组 编辑:程序博客网 时间:2024/06/05 04:31

这个版本是写的比较简单的,可以通过一键登陆校园网,免去多次页面跳转的操作和密码的输入方式。实质是模拟断开网络和重新连接两次操作,可能存在http错误(这个暂时没有考虑)。
优点:
帐密直接嵌入到html中即可;
通过ajax免去页面的跳转,最终实现一个页面直接完成所有操作;
ps:虽然不是什么很牛的方法,室友不愿意尝试新东西好可惜。

<head>    <meta charset="utf-8"></head><body><script>    var XMLHttpReq;    function createXMLHttpRequest() {        try {            XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");          }        catch(E) {            try {                XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");            }            catch(E) {                XMLHttpReq = new XMLHttpRequest();            }        }    }    function sendAjaxRequest(url) {        createXMLHttpRequest();        XMLHttpReq.open("post", url, true);        XMLHttpReq.send(null);    }    window.onload = function(){            url = "http://ipgw.neu.edu.cn/ipgw/ipgw.ipgw?uid=stu_xxxxxxxx&password=xxxxx&operation=disconnectall&range=2&timeout=1";              sendAjaxRequest(url);            url = "http://ipgw.neu.edu.cn/ipgw/ipgw.ipgw?uid=stu_xxxxxxxx&password=xxxxx&operation=connect&range=2&timeout=1";            sendAjaxRequest(url);            window.close();    }</script></body>
0 0