Home > Web Front-end > JS Tutorial > Introduction to methods of dynamically creating script tags to achieve cross-domain resource access_javascript skills

Introduction to methods of dynamically creating script tags to achieve cross-domain resource access_javascript skills

WBOY
Release: 2016-05-16 16:57:54
Original
1699 people have browsed it

login.html

复制代码 代码如下:

<script> <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></script>

用户名:
密码:



login.jsp
复制代码 代码如下:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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");
 <%
}
%>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template