위치 객체로그인

위치 객체

위치 객체는 현재 페이지의 URL 정보를 나타냅니다. 예를 들어 전체 URL:

http://www.example.com:8080/path/index.html?a=1&b=2#TOP

는 location.href를 사용하여 얻을 수 있습니다. URL의 각 부분의 값을 얻으려면 다음과 같이 작성할 수 있습니다.

location.protocol; // 'http'
location.host; // 'www.example.com'
location.port; // '8080'
location.pathname; // '/path/index.html'
location.search; // '?a=1&b=2'
location.hash; // 'TOP'

새 페이지를 로드하려면 location.sign()을 호출할 수 있습니다. 현재 페이지를 다시 로드하려면 location.reload() 메서드를 호출하는 것이 매우 편리합니다.

위치 개체 속성:

QQ截图20161012171542.png

위치 개체 메서드:

QQ截图20161012171548.png

다음 섹션
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>location</title> </head> <script type="text/javascript"> var myurl=window.location.href; document.write("当前网址:"+myurl); </script> </head> <body> </body>
코스웨어