자바스크립트 document.href를 제공했습니다. 및 document.target 링크에서 href 및 target 속성을 가져옵니다. 링크는 일반적으로
href 속성 찾기
href 속성을 가져오려면 document.href 사용되어야 합니다. 다음 예에서 href 속성은 "https://www.tutorialspoint.com/"이라는 링크로 구성되며 프로그램이 실행되면 표시됩니다.
예시
<html> <body> <p><a id="myId" href="https://www.tutorialspoint.com/">tutorialspoint</a></p> <script> var ref = document.getElementById("myId").href; document.write(ref); </script> </body> </html>
출력
tutorialspoint https://www.tutorialspoint.com/
대상 속성 찾기
대상 을 얻으려면 속성, document.target 사용되어야 합니다. 다음 예에서 대상 속성 "_union "가 프로그램 실행 시 표시되었습니다.
예시
<html> <body> <p><a id="myId" target="_union" href="https://www.tutorialspoint.com/">tutorialspoint</a></p> <script> var ref = document.getElementById("myId").target; document.write(ref); </script> </body> </html>
출력
tutorialspoint _union