这个小程序是用来登陆百度的,登录百度后会自动弹出一个登录后http://passport.baidu.com/center页面,请问怎么登录后不弹出任何网页,就返回一个登陆成功或者不成功?

解决方案 »

  1.   

    function submitArticle(main){
      var content = "<form name='form2'  id='form2' action=http://passport.baidu.com/?login method=post target='_blank' style='border:0px; padding:0px; margin:0px;'>";
    content += "  <INPUT type=hidden value=sp name=tpl> ";
    content += "  <INPUT type=hidden value=sp name=tpl_reg>";
    content += "  <TABLE cellSpacing=0 cellPadding=4 width=218 align=center border=0>";
    content += "  <TBODY>  <TR> <TD class=f14 width=56>用户名:</TD> <TD><INPUT class=ip name=username value=''></TD></TR>";
    content += "  <TR> <TD class=f14>密 码:</TD><TD><INPUT class=ip type=password name=password value =''></TD> </TR><TR>";
    content += "   <TD>&nbsp;</TD> <TD><INPUT type=submit value=' 登录 ' name=Submitlogin><A    href='http://passport.baidu.com/?getpass'   target=_blank>忘记密码?</A></TD></TR>  </TBODY> </TABLE>";
    content += "    <HR style='BORDER-TOP: #aaaaaa 1px solid; WIDTH: 90%' align=center SIZE=0> ";
    content += "   </form>";
     
    content += "<form name='form1' id='popFormSubmit' action='' target='_blank' method='post'   style='border:0px; padding:0px; margin:0px;'>";
    content += "<input type='hidden' name='ct' value='1'/>";
    content += "<input type='hidden' name='cm' value='1'/>";
    content += "<div id='m_blognew' class='modbox''>";
    content += "<table border='0' cellspacing='6' cellpadding='3' class='formhd' width='90%' bgcolor='#ffffff' align='center'>"; content += "<tr><td width='60' class='f14' nowrap>标题:</td>"; content += "<td><input type='text' name='spBlogTitle' id='spBlogTitle' style='width:540px' value='uuuuuuuuuuu' onChange=''></td>";
    content += "<tr><td width='60' class='f14' nowrap>内容:</td><td><input type='text' name='spBlogText' id='spBlogText' style='width:140px' value='000' onChange=''></td></tr>";
    content += "<tr><td class='f14' nowrap>分类:</td>";
    content += "<td class='f14'><select id='spBlogCatName' name='spBlogCatName' style='width:90px' >";
    content += "<option value='默认分类'>默认分类</option>";
    content += "</select></td></tr>";
    content += "<tr><td class='f14' nowrap>评论:</td><td class='f14'><input name='spIsCmtAllow' type='radio' value='1' checked='checked' >允许 <input name='spIsCmtAllow' type='radio' value='0'>禁止</td>";

    content += "</tr><tr><td class='f14' nowrap>状态:</td><td><select name='spBlogPower' style='width:90px' ><option value='0' >公开</option><option value='1'>仅向好友开放</option><option value='3'>私有</option></select></td>";

    content += "<input type='hidden' name='tpl' value='sp'>";
    content += "</tr><tr><td>&nbsp;</td><td class='formsb'><input name='tj' type='submit' value=' 发表文章 ' ></td></tr></table></div></form>";
    content += "<td >结果返回<input type='text' name='loading' id='loading' style='width:540px' value='' onChange=''></td>";
      content += "<input type='text' name='posturl' value='http://hi.baidu.com/您的空间地址' style='width:300px; border:1px solid #006699'>形式如:http://hi.baidu.com/百度空间。>";
      content += "<input type='hidden' id=top name='top' value=''>"; $(main).innerHTML = content;
    $("tj").onclick = function submit_Button(){
    var actionurl=document.all("posturl");
    if(actionurl.value==""){
    alert("提交的空间地址不能为空");
    return false;}
    if(actionurl.value.replace("hi.baidu.com/")==actionurl.value){
    alert("地址错误,请输入您的百度空间地址");
    return false;}
    else
    {
    form1.action=actionurl.value +"/commit"; }
        ajaxSubmitForm(form1);
      // alert(postContent2);
      //ajaxSubmit(form1.action, form1.method, postContent1,loading);  }
    /* $("Submitlogin").onclick = function Login_Button(){
    alert("1");
       $("login").innerHTML = "<iframe width=100 height=100 src="+ ajaxSubmitForm(form2)+"></iframe>已生成框架";
       getHtml("http://passport.baidu.com/?login&username=gl19820809&password=198289","doArticle('111');");  // alert(postContent2);
      //ajaxSubmit(form1.action, form1.method, postContent1,loading);  }*/
    }function ajaxSubmitForm(form) { var elements = form.elements;// Enumeration the form elements
    var element;
    var i;
    var postContent = "";// Form contents need to submit
    for(i=0;i<elements.length;++i) {
    var element=elements[i];
    if(element.type=="text" || element.type=="textarea" || element.type=="hidden") {
    postContent += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value) + "&";
    }
    else if(element.type=="select-one"||element.type=="select-multiple") {
    var options=element.options,j,item;
    for(j=0;j<options.length;++j){
    item=options[j];
    if(item.selected) {
    postContent += encodeURIComponent(element.name) + "=" + encodeURIComponent(item.value) + "&";
    }
    }
    } else if(element.type=="checkbox"||element.type=="radio") {
    if(element.checked) {
    postContent += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value) + "&";
    }
    } else if(element.type=="file") {
    if(element.value != "") {
    postContent += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value) + "&";
    }
    } else {
    postContent += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value) + "&";
    }
    }
           ajaxSubmit(form.action, form.method, postContent);
    }
    function ajaxSubmit(url, method, postContent)
    { var loadingDiv = document.getElementById('loading');
    // call in new thread to allow ui to update
    window.setTimeout(function () {
    loadingDiv.innerText = "Loading....";
    loadingDiv.style.display = "";
    }, 1);
    // code for Mozilla, etc.
    if (window.XMLHttpRequest)
    {
    xmlhttp=new XMLHttpRequest();
    }
    // code for IE
    else if (window.ActiveXObject)
    {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    } if(xmlhttp) {
    xmlhttp.onreadystatechange = function() {
    // if xmlhttp shows "loaded"
    if (xmlhttp.readyState==4)
    {
    if(true) {
    var result = document.createElement("DIV");
    result.style.border="1px solid #363636";
    result.innerHTML = xmlhttp.responseText;
    document.body.appendChild(result);
    } else {
    var result = document.createElement("DIV");
    result.style.border="1px solid #363636";
    result.innerHTML = xmlhttp.responseText;
    document.body.appendChild(result);
    }
    loadingDiv.innerText = "Submit finnished!";
    }
    };
    if(method.toLowerCase() == "get") {
    xmlhttp.open("GET", url + "?" + postContent, true);
    xmlhttp.send(null);
    } else if(method.toLowerCase() == "post") {
    xmlhttp.open("POST", url, true);
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(postContent);
    }
    } else {
    loadingDiv.innerHTML =
    "Can't create XMLHttpRequest object, please check your web browser.";
    }
    }
      

  2.   

    晕...这代码...还要找jQuery,还要写对应的HTML元素...不好看啊...
    如果直接提交到白肚的Server然后回写HTML的话,肯定会弹出窗口的.注意了一下你的这段:
    if(true) {
    var result = document.createElement("DIV");
    result.style.border="1px solid #363636";
    result.innerHTML = xmlhttp.responseText;
    document.body.appendChild(result);
    }如果没有理解错,这里在把xmlhttp.responseText写到result.innerHTML之前,使用JS的replace函数把弹出窗口的那段JS去掉即可.但是我不知道这段JS是什么,因为我对白肚没什么好感,所以没有账号...
      

  3.   

    无论怎么提交  都会传给服务器一个登陆地址的
    然后打开的页面是服务器本身要跳转的他会打开一个session
    如果咱们把这个关闭的话 那肯定session也就失效了以我的理解,高手给看看有啥办法么?我理解的对么?