2012-09-30 9 views
1

이 코드를 작동시키지 못하면 iframe을 새로 고칠 때 iframe이 자동으로 아래로 스크롤됩니다.iframe이 자동으로 아래쪽으로 스크롤

FIDDLE

는 CODE : 사람 CN

<html> 
<!-- 
    Created using jsbin.com 
    Source can be edited via http://jsbin.com/ujuci5/2/edit 
--> 
<head> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
</head> 
<body> 
    <p>iframe:</p> 
    <iframe src="http://jsbin.com/aloko5" id="frame" frameborder="0" width="200px" height="300px"></iframe> 
<script> 
$(window).load(function() 
{ 
    var $contents = $('#frame').contents(); 
    $contents.scrollTop($contents.height()); 
}); 
</script> 

</body> 
</html>​ 

이 좀 도와, 내가 좀

+0

당신의 바이올린은 Mootools의를 사용해야했다. 하지만 코드가 jQuery를 호출합니다. 귀하의 바이올린 설정이 잘못 되었습니까? –

+1

프레임을 수정할 수 없습니다. * 안전하지 않은 JavaScript는 http://fiddle.jshell.net/_display/이있는 프레임에서 URL http://jsbin.com/aloko5가있는 프레임에 액세스하려고 시도합니다. 도메인, 프로토콜 및 포트가 일치해야합니다. * – Blender

+0

내 데스크톱에서 여전히 안전 URL이더라도 스크롤 다운하지 않았습니다. – telexper

답변

0

붙어있어 당신은 iframe이 내 코드에 액세스 할 수 있습니까? iframe 코드 자체 내에서 scrollTop을 설정해야한다고 생각합니다. 예를 들어

:

$("body").scrollTop(100); 

편집 : 여기에 더 많은 정보를 찾을 : How to get scrollTop of an iframe

0

창에서 iframe이의 하나 그 자체가 아니라 그한다 가로 챌 수하는 onLoad 이벤트.

또한 Blender의 의견은 부분적으로 유효합니다.

iframe에서 열린 문서가 상위 문서와 동일한 도메인에 속한 경우에만이 설정이 작동합니다. 그리고 같은 프로토콜 :

- http://domain/main.aspx as the container and http://domain/inner.aspx at the iframe is valid 
- http://domain/main.aspx as the container and https://domain/inner.aspx at the iframe will be blocked 
- http://domain/main.aspx as the container and http://another/inner.aspx at the frame will also be blocked 

(내 PDA에서 전송)

관련 문제