기초가 없는 나에게ㅠㅠ



어제 OKKY에 질문을 하나 올렸당.

document와 contentDocument의 차이가 뭔가여?

근데 아무도 대답해주지않았다ㅠㅠ

구글에 difference between contentdocument and document 라고만 검색해서 아무것도 안나왔다ㅠㅠ




그래서 오늘아침 답변이 안달린걸보고 그냥 따로따로 찾기로 결심!




* document (HTML DOM Document Object)

When an HTML document is loaded into a web browser, it becomes a document object.

The document object is the root node of the HTML document.






*contentDocument(HTML DOM IFrame Object의 Method)

The contentDocument property returns the Document object generated by a frame or iframe element.

This property can be used in the host window to access the Document object that belongs to a frame or iframe element.




document는 그냥 웹페이지 그 자체고

contentDocument는 html iframe 안의 메소드여따..




그리고 내가 해결하고싶었던
window.createPopup = function (){
        var popup = document.createElement("iframe"),
            isShown = false, popupClicked = false;
        popup.src = "about:blank";
        popup.style.position = "absolute";
        popup.style.border = "0px";
        popup.style.display = "none";
     
    popup.addEventListener("load", function(e){
            popup.document = (popup.contentWindow || popup.contentDocument);
            if(popup.document.document) popup.document = popup.document.document;
            console.log("1:",popup.document);
        });
    document.body.appendChild (popup);
   
        return popup;
};

var calPopup = window.createPopup();
console.log("2:",calPopup.contentDocument);
}

요로케 popup은document고 calPopup은 contentDcument여야 접근이 가능해서
어떻게 calPopup을 document로 접근하나 했는데


 w3schools에 기초 example에 있었다ㅠㅠ

var x = document.getElementById("myframe");
var y = (x.contentWindow || x.contentDocument);
if (y.document)y = y.document;

띠용 본문코드에도 있었따.. 스바.. ㅎㅎ

Comments

Popular posts from this blog

STS/이클립스 Java Virtual Machine Launcher 오류 (ini파일, jdk 수정해도 안될때)

[Spring Boot] jsp파일에서 application.properties 값 바로 사용하기!!!

1998년도 구룡초등학교 재학생을 찾습니다.