내부에 iframe이있는 페이지를 작성했습니다. 구조는 다음과 같습니다.
count.html :
/* http://example.com/count.html */
<div class="primary">
<h2>Countdown</h2>
<div class="content">
<iframe src="page2.html" id="iframe"></iframe>
</div>
</div>
index.html :
/* http://example.com/index.html */
<div class="primary">
<h2>Home</h2>
<div class="content">
<iframe src="home.html" id="iframe"></iframe>
</div>
</div>
page2.html :
<head>
<script>
var count = "<!--# echo time -->"; /* C code will control it*/
function display() {
if (wait_seconds == null) {
wait_seconds = (count == "" ? 180 : parseInt(count));
}
document.countdown.b.value = wait_seconds;
if (wait_seconds <= 0) {
if(redirect == null || redirect == "")
redirect = "index.html";
location.href = redirect;
return;
} else {
wait_seconds = wait_seconds-1;
}
window.setTimeout("display()", 1000);
}
</script>
</head>
<body>
<form name='countdown'>
<h2>Countdown Bar</h2>
<input type='text' size='2' name='b' disabled>
</form>
<script>
display();
</script>
</body>
나는 iframe ( page2.html
) 에 카운트 다운 바를 디자인했는데 , 시간이되면 count.html
새로 고침하고 기본 페이지로 변경하고 index.html
싶지만 페이지 새로 count.html
고침시에는 고정되어 iframe ( page2.html
) 만 새로 고침 되므로 시간 count.html
이 다되면 index.html
내부가있는 iframe , 그것을 고치는 방법?
[window.]location.href
현재 프레임의 위치를 제어합니다.
사용 [window.]top.location.href
은 최상위 문서의 위치를 제어합니다.
변경 location.href = redirectURL;
에top.location.href = redirectURL;
자세한 내용 은 window.location.href와 top.location.href의 차이점 을 참조하세요.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다