2013-02-28 2 views
2
  • iframe이있는 jsp 페이지가 있습니다. 예를 들어

: worklist.jsp자바 스크립트를 사용하여 iframe 다시로드

<html> 
<head> 
<body> 
<iframe height="15%" marginheight="0px" marginwidth="0px" scrolling="no" src="menuBanner.jsp" style="border:0; padding: 0px; position:absolute;" width="960px"> 
</iframe> 
<div><button data-dojo-type="dijit.form.Button" value="Reload" id="reload" onclick="reload();">Reload</button></div> 
</body></head></html> 
  • 버튼을 클릭에, 난은 iframe 페이지를 다시로드해야합니다.
  • 나는 아래의 스크립트를 시도하지만 전체 페이지를 (worklist.jsp)

기능을 다시로드() { location.reload()를 다시로드; }

+1

검사를 다시 할당합니다 [http://stackoverflow.com/questions/86428/whats-the-best-way-to-reload-an- iframe 허용하여 자바 스크립트] [1] [1] : http://stackoverflow.com/questions/86428/whats-the-best-way-to-reload-an-iframe-using-javascript –

+0

이것은 JSP와 완전히 관련이 없습니다. – NSPKUWCExi2pr8wVoGNk

답변

2
function reload({ 
    document.getElementById('iFrameID').contentDocument.location.reload(true); 
} 
+0

iframe 도메인이 상위 도메인과 일치하는 경우에만 작동합니다. – CharliePrynn

+0

감사합니다 .. 그 작업 – Rachel

3

src를 현재 src로 설정하여 iframe을 업데이트/새로 고침 할 수 있습니다.

다음은 예입니다.

var test = document.getElementById('iframeId'); 
test.src = iframe.src; 

이 방법은 교차 도메인에서 작동합니다. 댓글의 예는 iFrames가 동일한 도메인에있는 경우 덜 해킹됩니다.

1

당신은 시도 할 수 있습니다 :

var iframe = document.getElementById('YourIFrameId'); 
iframe.src = iframe.src + '?c=' + Math.random(); 

내가 당신의 iframe이를 다시로드 할 수 없습니다 속성 SRC를 변경하지 않고 생각합니다.

0

이렇게 할 수 있습니다. iframe이의 SRC를 확인하고이 iframe이의 SRC

<script> 
function test() 
    { 
    $('#subpage_frame').attr('src',$('#subpage_frame').attr('src')) ; 
    } 
</script> 

<iframe src="test.com" onload="Loaded();" id="subpage_frame"></iframe> 

<button onclick="test();">Refresh button</button> 
관련 문제