<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>location</title>
</head>
<script type="text/javascript">
var myhash=window.location.hash;
var myhost=window.location.host;
var myhostname=window.location.hostname;
var myhref=window.location.href;
var mypathname=window.location.pathname;
var myport=window.location.port;
var myprotocol=window.location.protocol;
var mysearch=window.location.search;
document.write("当前从#开始的URL值为:"+myhash+"<br />");
document.write("当前主机名和当前URL的端口号为:"+myhost+"<br />");
document.write("当前URL的主机名为:"+myhostname+"<br />");
document.write("当前完整的URL为:"+myhref+"<br />");
document.write("当前URL的路径部分为:"+mypathname+"<br />");
document.write("当前URL的端口号为:"+myport+"<br />");
document.write("当前URL的协议为:"+myprotocol+"<br />");
document.write("当前从问号(?)开始的URL(查询部分)为:"+mysearch);
</script><body></body></html>