Location对象
location用于获取或设置窗体的URL,并且可以用于解析URL。
语法:
location.[属性|方法]
location对象属性图示:
location 对象属性:
location 对象方法:
任务
在右边编辑器script标签内,获取当前显示文档的URL,并输出。
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>location</title></head><script type="text/javascript">document.write(location.protocol+"//"+location.hostname+location.port+location.pathname+location.search+location.hash+"<br>"); function currenturl(){alert(window.location); } </script></head><body><input type="button" value="获取网页地址" οnclick="currenturl()"></body></html>
JS window对象 Location对象 location用于获取或设置窗体的URL 并且可以用于解析URL。 语法: location.[属性|方法]...