我们有几个不同的系统,每一个系统都有不同的用户名和密码,这样导致很多员工遗忘密码的情况发生,所以打算打一个一键登录的功能,我想的办法是,模拟写一个登录页面,代码简述如下.<html>
<head>
<script type="text/javascript">
myform.submit();
</script>
<body>
<form action="目标网站" name="myform" method="post">
<input type="hidden" value="123" name="loginname" />
<input type="hidden" value="456" name="password" />
</form>
</body>
</head>
</html>以上代码是通过模拟一个登录页面来实现了跳过登录界面进行登录.
在以上功能的基础上,我想实现通过一键登录进入系统后,继续实现页面的跳转,
例如:自动登进去以后,我想自动跳到http://目标网站/目标页面.
对以上功能的实现,没有任何想法,就试着在
myform.submit()下增加了window.location="http://目标网站//目标页面
增加了上述一句代码后,不仅没实现跳转功能,原来的一键登录也不能工作,系统只是简单的去了目标网站的登录的界面.
不知道各位有没有这种需求,以及是怎么实现的.希望可以提个醒.
<head>
<script type="text/javascript">
myform.submit();
</script>
<body>
<form action="目标网站" name="myform" method="post">
<input type="hidden" value="123" name="loginname" />
<input type="hidden" value="456" name="password" />
</form>
</body>
</head>
</html>以上代码是通过模拟一个登录页面来实现了跳过登录界面进行登录.
在以上功能的基础上,我想实现通过一键登录进入系统后,继续实现页面的跳转,
例如:自动登进去以后,我想自动跳到http://目标网站/目标页面.
对以上功能的实现,没有任何想法,就试着在
myform.submit()下增加了window.location="http://目标网站//目标页面
增加了上述一句代码后,不仅没实现跳转功能,原来的一键登录也不能工作,系统只是简单的去了目标网站的登录的界面.
不知道各位有没有这种需求,以及是怎么实现的.希望可以提个醒.
解决方案 »
- 很简单的问题,谁来帮我解说一下c#的递归算法
- 关于通过DropDownList做查询条件GridView来显示的问题
- 关于数据库储存过程.
- 不用怎样使得window.open();弹出窗口不被拦截?急!!!!
- 请问在C#里
- Microsoft JScript 运行时错误: 无法设置属性“innerHTML”的值: 对象为 null 或未定义
- 大家谁遇到过这个错误?(CS1595: 已在多处定义“article.article_display”)
- 学习ASP.net怎么开始学啊?
- 窗体间参数传递问题,
- MVC 找了很多都没解决 求助 用户代码未处理 System.Data.ProviderIncompatibleException
- iis上的wcf无法访问,提示:协议绑定“*:80:”对“http”无效
- 索引超出范围。必须为非负值并小于集合大小。
给登录页post帐号和密码,获取响应的信息.如果响应的信息是登录成功标记则跳转到相应的页面
sb.Append("pwd=1");
string vpcURL = "https://目标页面";
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
byte[] response = webClient.UploadData(vpcURL, "POST", System.Text.Encoding.ASCII.GetBytes(sb.ToString()));
string responseData = System.Text.Encoding.ASCII.GetString(response, 0, response.Length);在目标页面接收传来的参数
try{
foreach (string item in Page.Request.Form) {if (Page.Request.Form[item] != ""){}}
}catch{}
所以我又看了一个目标网站的源代码,发现它也是用post发送的提交,可我将他们的源代码贴到我
的程序中,并不能像它那样post. <script type="text/javascript">
function GetPageSize() {
var scrW, scrH;
if (window.innerHeight && window.scrollMaxY) {
// Mozilla
scrW = window.innerWidth + window.scrollMaxX;
scrH = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight) {
// all but IE Mac
scrW = document.body.scrollWidth;
scrH = document.body.scrollHeight;
} else if (document.body) {
// IE Mac
scrW = document.body.offsetWidth;
scrH = document.body.offsetHeight;
}
var winW, winH;
if (window.innerHeight) {
// all except IE
winW = window.innerWidth;
winH = window.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
// IE 6 Strict Mode
winW = document.documentElement.clientWidth;
winH = document.documentElement.clientHeight;
} else if (document.body) {
// other
winW = document.body.clientWidth;
winH = document.body.clientHeight;
}
// for small pages with total size less then the viewport
var pageW = (scrW < winW) ? winW : scrW;
var pageH = (scrH < winH) ? winH : scrH;
return { PageW: pageW, PageH: pageH, WinW: winW, WinH: winH };
}
function setPageSize() {
//处理浏览器窗口大小信息
var winInfo = GetPageSize();
//alert("pageW:"+winInfo.PageW+"pageH:"+winInfo.PageH+"winW:"+winInfo.WinW+"winH:"+winInfo.WinH);
loginForm.clientWidthScreen.value = winInfo.WinW;
loginForm.clientHeightScreen.value = winInfo.WinH;
loginForm.pageWidthScreen.value = winInfo.PageW;
loginForm.pageHeightScreen.value = winInfo.PageH;
//alert(loginForm.clientWidthScreen.value);
}
function loginUser() {
setPageSize(); //获取当前窗口大小进行保存 var url = "http://1.2.3.4/loginAction_loginUserForInterface.action";
var loginname = "123";
var userId = "";
var password = "111";
var fydm = "M53";
var loginType = "1";
var datas = {
loginname: loginname,
userId: userId,
password: password,
fydm: fydm
}
$.post(url, datas, function (data) {
if (data == 'true') {
location.href = "/view/sbxx/sbxxlist.jsp";
} function searchfy() {
var url = "/xtgl/gnqxgl/showtree.jsp?type=login";
dialog("法院选择", "iframe:" + url, "350", "450", "iframe");
} $(document).ready(function () {
loginUser();
});
</script>
</head>
<body>
<form name="loginForm" action="" method="post">
<input name="clientWidthScreen" type="hidden" value="1024" />
<input name="clientHeightScreen" type="hidden" value="768" />
<input name="pageWidthScreen" type="hidden" value="1024" />
<input name="pageHeightScreen" type="hidden" value="768" />
</form>
</body>
</html>
<script type="text/javascript">
$(document).ready(function () {
//window.open("http://www.baidu.com");
//window.open ('MessageBoard.jsp', 'MessageWindow', 'height=300, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no')
setPageSize();
});
function setPageSize() {
//处理浏览器窗口大小信息
var winInfo = GetPageSize();
//alert("pageW:"+winInfo.PageW+"pageH:"+winInfo.PageH+"winW:"+winInfo.WinW+"winH:"+winInfo.WinH);
loginForm.clientWidthScreen.value = winInfo.WinW;
loginForm.clientHeightScreen.value = winInfo.WinH;
loginForm.pageWidthScreen.value = winInfo.PageW;
loginForm.pageHeightScreen.value = winInfo.PageH;
//alert(loginForm.clientWidthScreen.value);
}
</script>
我用wireshark抓了一下包,发现在它的原网站post出去以后,数据和form用submit提交的一样,而我用相同代码执行,却发出去的包不一样.
原网站发出的是:POST /loginAction_loginUserForInterface.action HTTP/1.1 (application/x-www.form-urlencoded)
而我发出的是:OPTIONS /loginAction_loginUserForInterface.action HTTP/1.1
我来帮你做。var url=根据一键登录所选的地址。
$.post(url,{"name":"123","pwd":"123"}function(data) {
if (data == null || data == "") {
}
else {
if(data==1){跳转}
}
});
logina.aspxtry{
if(page.request.form["name"]!=null&&page.request.form["pwd"]!=null)//这个地方你再严谨些
{去数据库验证,通过返回1}
}catch{}
loginb.aspx同理
可能真是这个问题,我是不是一个项目,我是学着自己系统,然后跳过其它系统的登录页面到特定页面,如果用getJSON的话,它是get方式,我这好象只能用post方式.
一句话,你能不能改其他系统的登录界面的代码?logina.aspx loginb.aspx