HTML 페이지 점프 의 5 가지 방법 [회전]
                                            
 3606 단어  JavaScripthtmlmetarefresh카운트다운
                    
다음은 다섯 가지 예 를 들 어 상세 하 게 설명 한다. 이 몇 가지 예 의 주요 기능 은 5 초 후에 같은 디 렉 터 리 에 있 는 hello. html (자신의 필요 에 따라 스스로 수정) 파일 로 자동 으로 이동 하 는 것 이다.
1) html 의 실현
<head>
	<!--                  -->
	<meta http-equiv="refresh" content="10">
	<!--              -->
        <meta http-equiv="refresh" content="5;url=hello.html"> 
</head>2) 자 바스 크 립 트 의 실현
<script language="javascript" type="text/javascript"> 
    //         
    window.location.href='hello.html';
    //         
    setTimeout("javascript:location.href='hello.html'", 5000); 
</script>장점: 유연성, 더 많은 다른 기능 결합 가능
단점: 브 라 우 저의 영향 을 받 습 니 다.
3) 마지막 자 바스 크 립 트 구현 (IE)
 <span id="totalSecond">5</span>
 <script language="javascript" type="text/javascript"> 
	var second = totalSecond.innerText; 
	setInterval("redirect()", 1000); 
	function redirect(){ 
	totalSecond.innerText=--second; 
	if(second<0) location.href='hello.html'; 
	} 
 </script>장점: 더욱 인성 화
단점: Firefox 는 지원 하지 않 습 니 다 (Firefox 는 span, div 등의 innerText 속성 을 지원 하지 않 습 니 다)
Fixfox
<script language="javascript" type="text/javascript"> 
	var second =    document.getElementByIdx_x('totalSecond').textContent; 
	setInterval("redirect()", 1000); 
	function redirect() 
	{ 
	document.getElementByIdx_x('totalSecond').textContent = --second; 
	if (second < 0) location.href = 'hello.html'; 
	} 
</script>4) Firefox 가 innerText 를 지원 하지 않 는 문 제 를 해결 합 니 다.
<span id="totalSecond">5</span>
	<script language="javascript" type="text/javascript"> 
	if(navigator.appName.indexOf("Explorer") > -1){ 
	document.getElementByIdx_x('totalSecond').innerText = "my text innerText"; 
	} else{ 
	document.getElementByIdx_x('totalSecond').textContent = "my text textContent"; 
	} 
</script>
 5) 통합
<span id="totalSecond">5</span>
	  
<script language="javascript" type="text/javascript"> 
	var second = document.getElementByIdx_x('totalSecond').textContent; 
	  
	if (navigator.appName.indexOf("Explorer") > -1)  { 
	    second = document.getElementByIdx_x('totalSecond').innerText; 
	} else { 
	    second = document.getElementByIdx_x('totalSecond').textContent; 
	} 
	  
	setInterval("redirect()", 1000); 
	function redirect() { 
	if (second < 0) { 
	    location.href = 'hello.html'; 
	} else { 
	    if (navigator.appName.indexOf("Explorer") > -1) { 
	        document.getElementByIdx_x('totalSecond').innerText = second--; 
	    } else { 
	        document.getElementByIdx_x('totalSecond').textContent = second--; 
	    } 
	} 
	} 
</script>이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
기초 정리 - 1문자 (String) 숫자 (Number) 불린 (Boolean) null undefined 심볼 (Symbol) 큰정수 (BigInt) 따옴표로 묶어 있어야 함 Not-A-Number - 숫자 데이터 / 숫자로 표...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.