JavaScript:Document
Document 인터페이스는 브라우저가 불러온 웹 페이지를 나타내며, 페이지 콘텐츠(DOM 트리)의 진입점 역할을 수행합니다. DOM 트리는
<body>
와
<table>및 여러 다른 요소를 포함합니다. Document는 페이지의 URL을 얻거나 문서에 새로운 요소를 생성하는 등의 기능을 전역적으로 제공합니다.
Document 인터페이스는 모든 종류의 문서에 대한 공통의 속성과 메서드를 묘사합니다. 문서의 유형(HTML, XML, SVG 등)에 따라서 더 다양한 API가 존재합니다. 예컨대 "text/html" 콘텐츠 유형으로 제공되는 HTML 문서는 HTMLDocument 인터페이스도 구현하는 반면, XML과 SVG 문서는 XMLDocument 인터페이스를 구현합니다.
브라우저 URL 속성 받는 방법
- Stackoverflow - Using $location.protocol() and $location.host() in Vuejs application
-
document.location.protocol
for protocol -
document.location.host
for the current host - or just
document.location.origin
forprotocol+'://'+host
APIs
createElement
- Document.createElement() - Web API | MDN
- JavaScript / 요소 추가하기 / .createElement(), .createTextNode(), .appendChild() – CODING FACTORY
새로운 요소를 만듭니다.
은 다음과 같은 코드를 생성합니다.
추가된 요소는 Node.appendChild() 또는 Node.insertBefore() 사용하여 노드를 추가한다.