2011-02-01 2 views
2
if(window.top!==window.self){document.write=""; 
window.top.location=window.self.location; 
setTimeout(function(){document.body.innerHTML=""},1); 
window.self.onload=function(){document.body.innerHTML=""}}; 

이렇게하면 페이지가 iframe 내부에 렌더링되지 않습니까?이 창은 무엇입니까? 이 iframe을 확인합니까?

답변

2

예입니다. 그렇다면이 스크립트 시도가 부모 프레임이 아닌 경우 시도하는 것처럼 보일 수 있습니다. Pointy가 말했듯이, 이들은 항상 작동하지 않습니다. Javascript는 해당 문서를 만들지 않는 한 대부분의 브라우저에서 해당 소유자 문서의 "탈주"할 수 없습니다. 또는 Javascript가 포함 된 페이지가 동일한 도메인 정책이 적용되지 않는 방식으로 동적으로로드 된 경우 (사이트가 iframe/프레임에있는 경우는 그렇지 않음) 다른 페이지에서 열어 보는 페이지의 경우 스크립트는에 부모 문서를 수정할 수있는 액세스 권한이 없어야합니다.

다음은 메모와 함께 여러 줄로 나누어 게시 한 코드입니다.

if(window.top!==window.self){ // is the outermost document not this document? 
    document.write=""; // write an empty text node to the document. (not sure why) 
    window.top.location=window.self.location; // set the parent document's location to this document's location. 
    setTimeout(function(){document.body.innerHTML=""}, 1); // after 1 millisecond make this document's HTML empty. (Probably a memory leak fix) 
    window.self.onload = function(){document.body.innerHTML=""} // Another memory leak fix to clear the current document when it is done loading. 
}; 
+0

'document.write' 호출과'innerHTML' 호출 자체를 제거하려는 시도라고 생각합니다. – Pointy

+0

@Pointy 또는 브라우저의 페이지 렌더링을 "느리게"설정할 수 있습니다. 'document.write'는 DOM을 변경하는 동기식/블로킹 방식이므로 문서의 일부가 다시 렌더링되도록합니다. – sholsinger

+0

맞아요. 코드가 "준비"또는 "로드"핸들러에서 실행되면 (페이지가 완전히 파싱되고 DOM이 완료된 후) 현재 DOM을 지울 것입니다. – Pointy

0

window.top은 브라우저의 맨 위 창을 나타냅니다. 간단한 단어는 브라우저 창 자체입니다.

코드가 비어있는 iframe을 모두 비우는 것 같습니다.

0

이렇게하면 페이지가 iframe 내부에 렌더링되지 않습니까?

iframe 또는 frame 예. 탈옥하려고합니다.