script 탭을 동적으로 만들어서 전역 자원 접근을 실현하는 방법 소개

2274 단어
login.html
 
  
<p></p> <p>function request(id,url){<br>     oScript = document.getElementById(id);<br>     var head = document.getElementsByTagName("head").item(0);<br>     if (oScript) {<br>        head.removeChild(oScript);<br>     }<br>     oScript = document.createElement("script");<br>     oScript.setAttribute("src", url);<br>     oScript.setAttribute("id",id);<br>     oScript.setAttribute("type","text/javascript");<br>     oScript.setAttribute("language","javascript");<br>     head.appendChild(oScript);<br>     return oScript;<br>}</p> <p> </p> <p>function userLogin(){<br>    var username=document.getElementById('name').value;<br>    var password=document.getElementById('password').value;<br><br>    //alert(username+"--"+password);<br><br> var url='http://127.0.0.1:8080/EasyCMS/login.jsp?name='+encodeURI(username)+'&password='+encodeURI(password)+'&s=' + (new Date()).getTime();</p> <p> //alert("url="+url);<br>    var login=request("loginScript",url);<br>}</p> <p>function myloginState(state){</p> <p>      alert("ret:"+state);<br>      if (state==0)<br>   {<br>  alert(" ");<br>   }<br>   else<br>   {<br>        alert(" ");<br>   }</p> <p>}</p> <p>






login.jsp
 
  

String name=request.getParameter("name");
String password=request.getParameter("password");
if (name.equals("admin") && password.equals("admin"))
{
 request.getSession().setAttribute("admin","admin");
 %>
 myloginState("0");
 }
else
{
 %>
  myloginState("1");
 }
%>

좋은 웹페이지 즐겨찾기