Head request:
HEAD requests are very simple; you can use "head" (instead of "get" or "Post") as the first parameter to callopen()
Method.
When you generate a head request like this, the server does not return a real response like a get or POST request. On the contrary, the server only returnsHeader)This includes the last modification time of the content in the response, whether the requested resource exists, and many other useful information.
Output the content of the Response Header obtained from the head request:
Function updatepage (){
If (request. readystate = 4 ){
Alert (request. getAllResponseHeaders ());
}
}
Therefore, to obtain the response length, you only need to callrequest.getResponseHeader("Content-Length");
Example: iframe.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Example of remote scripting in an IFRAME</title>
<script type="text/javascript">
function handleResponse() {
alert('this function is called from server.html');
}
</script>
<body>
<Iframe id="beforexhr"
name="beforexhra" src="netease_jimmy_missyou1024.jpg"
style="border:10px solid blue" align=center
width="500" height="500" marginHeight=20 marginWidth=20 scrolling="yes"
frameborder="0"></iframe>
<a href="server.html" target="beforexhra">call the server</a>
</body>
Server.xml
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>the server</title>
<script type="text/javascript">
window.parent.handleResponse();
</script>
<body>
</body>
Note:
window.parent:
Obtains the parent window or parent frame of a framework. The parent of the top-level window references itself.
Target attribute:
1. _ blank
<A href = "document.html" target = "_ blank"> my document </a>
The browser opens a new window to display the document.html document.
2. _ parent
<A href = "document.html" target = "_ parent"> my document </a>
Pointing to parent frameset document
3. _ Self
<A href = "document.html" target = "_ Self"> my document </a>
Transfer the document to the current page
4. _ top
<A href = "document.html" target = "_ top"> my document </a>
Drop all webpages and replace the frameset document with document.html
Tip 1: Make others' page boxes unable to reference Your webpage
Add <base target = "_ top"> to the file header.
Tip 2: open a connection on the current page or refresh it and submit it to the current page.
Add <base target = "_ Self"> to the file header.