찾다
  • 로그인
  • 가입
비밀번호 재설정 성공

당신이 관심을 갖고 있는 프로젝트를 팔로우하고 그들에 관한 최신 뉴스를 맛보세요

위치 객체

위치 객체는 현재 페이지의 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>
시사 Clear
  • 코스 추천
  • 코스웨어 다운로드