项目开发中需要在本网站的链接中直接链接到其他网站中,而不需要输入用户名密码登陆该网站,本来想直接给个类似下面的链接:
http://www.swpu.edu.cn/AutoLoginEmail.aspx?uname=wx&pwd=123
但是该网站是先用AJAX方法验证用户名密码,再转向主页,需要两步,本想在自己的网页中JS中使EXT.AJAX模拟提交,用如下方法调用,
Ext.Ajax.request({
url :'http://211.70.67.90/loginAction!login.action',
mehtod : 'post',
scriptTag: true,
params : {
uname : 'wx',
pwd : '123'
},
success : function(resp, opts) {
window.location = "http://211.70.67.90/indexAction!gotoIndexPage.action";
},
failure : function(resp, opts) {
}
});
先通过 ajax http://211.70.67.90/loginAction!login.action 验证,
然后转向http://211.70.67.90/indexAction!gotoIndexPage.action
但是涉及到跨域访问,权限不够
于是想了个笨办法,在页面中加载两次窗体,中间间隔一个ALERT,实现模拟登陆,缺点每次需点击弹出窗体
<script type="text/javascript">
window.location ="http://211.70.67.90/loginAction!login.action?username=wx&password=123";
alert ('进入页面');
window.location = "http://211.70.67.90/indexAction!gotoIndexPage.action";
</script>