Backstage management always use frameset to be divided into parts for management, but feel very bad use, especially the page between the switch also to Judge Window.parent, too make me bother, so learn to use XMLHttpRequest page local refresh. The code is as follows:
Java code
- <script type="Text/javascript" >
- Window.onload = function () {
- document.getElementById ("email"). onblur = function () {
- if (window. XMLHttpRequest) {
- Http_request = new XMLHttpRequest ();
- if (http_request.overridemimetype) {
- Http_request.overridemimetype ("Text/xml");
- }
- }Else if (window. ActiveXObject) {
- try{
- Http_request = new ActiveXObject ("msxml2.xmlhttp");
- }catch (e) {
- try{
- Http_request = new ActiveXObject ("Microsoft.XMLHTTP");
- }catch (e) {}
- }
- }
- if (!http_request) {
- Window.alert ("Cannot create XMLHttpRequest object instance! ");
- return false;
- }
- Http_request.onreadystatechange = function () {
- if (http_request.readystate = = 4 &&
- Http_request.status = = ) {
- document.getElementById ("Emailtip"). InnerHTML
- =http_request.responsetext;
- }
- };
- Http_request.open ("GET", "email.jsp?email=" +This.value, true);
- Http_request.send (null);
- }
- }
- </script>
- <body>
- <input type="button" value="Modify" onclick="getothermessage ();"/>
- <input type="text" id="email"/>
- <span id="Emailtip" ></span>
- <div id="View" >
- 456
- </div>
- </body>
After the master reminds, you can use Ajax technology to write, using jquery is very simple, examples are as follows:
Java code
- <script type="Text/javascript" src="js/jquery.js" ></script>
- <script type="Text/javascript" >
- function Getothermessage () {
- $.ajax ({
- Type:"POST",
- URL:"${pagecontext.request.contextpath}/getothermessage.do",
- Success:function (msg) {
- $ ("#view"). HTML (msg);
- },
- Error:function () {
- Alert ("wrong");
- }
- });
- }
- </script>
- <body>
- <input type="button" value="Modify" onclick="getothermessage ();"/>
- <div id="View" >
- 456
- </div>
- </body>