HTML 페이지 프레임을 자동으로 제거하려면 어떻게해야합니까?
-
03-07-2019 - |
문제
페이지 프레임을 자동으로 제거하는 가장 좋은 방법은 무엇입니까?
전에이 유형의 코드를 사용했습니다.
<script language="JavaScript">
setTimeout ("changePage()", 3000);
function changePage() {
if (self.parent.frames.length != 0)
self.parent.location="http://www.example.com";
}
</script>
해결책
누군가가 당신의 콘텐츠 주위에 프레임을 넣은 경우를 의미합니까? 그렇다면 iframe에서 뛰어 내리려면 HTML 페이지의 다음 위치가 필요합니다.
<script type="text/javascript">
if (window.top.location != window.location) {
window.top.location = window.location;
}
</script>
다른 팁
다음은 부모 URL의 이름을 지정하지 않거나 별도의 기능 호출을 사용한다는 점에서 더 일반적인 대안입니다.
// is the current page at the top of the browser window hierarchy?
if (top.location != self.location)
{
// it isn't, so force this page to be at
// the top of the hierarchy, in its own window
top.location = self.location
}
역사상 프레임 브레이크 단계가 나타나지 않으려면 이렇게하십시오.
if ( self.location !== top.location )
{
top.location.replace( self.location );
}
제휴하지 않습니다 StackOverflow