iframe이있는 페이지가 있습니다. 이 iframe에 애니메이션을로드하려고합니다. 각 콘텐츠는 자바 스크립트/jquery 스크립트에 대한 참조가 포함 된 html 페이지로, 대부분의 애니메이션을 처리합니다. 예를 들면 :
content.html
<head>
<link rel="stylesheet" type="text/css" href="css/slide.css">
<script src="js/library/big_slide_img.js"></script>
</head>
<body>
<img class="big_slide_img" src="http://25.media.tumblr.com/0ab6f805c5a3591168e2fe2133552054/tumblr_mk52iuvbNI1s631nvo1_1280.jpg">
</body>
big_slide_img.js가로드되는 방법
$(window).load(function()
{
$("#iframe").contents().find('.big_slide_img').animate({left: '-=521'}, 800,function(){});
});
loadSlide = function(slide_no)
{
$.ajax(
{
url: "http://myurl.com",
async: false,
jsonpCallback: 'jsonCallback',
contentType: "application/json",
type: "GET",
dataType: "jsonp",
data: {"action": "loadall"},
success: function(data)
{
$('#frame_title').html(data.title);
$('#text').html(data.text);
$('#iframe').contents().find('html').html(data.animation);
},
error: function (event, jqXHR, ajaxSettings, thrownError)
{
alert('[event:' + event + '], [jqXHR:' + jqXHR + '], [ajaxSettings:' + ajaxSettings + '], [thrownError:' + thrownError + '])');
}
});
};
내 문제
애니메이션이 일치하지 않아 $ (window) .load가 예상대로 대기하지 않는 것으로 판단됩니다. 지연으로 모든 문제가 해결됩니다.
$(window).load(function()
{
$("#iframe").contents().find('.big_slide_img').delay(800).animate({left: '521'}, 800,function(){});
});
지연없이 어떻게 처리합니까? 이 파일에 어떤 코드가 있는지 모르기 때문에 외부에서 iframe을 모니터링하지 않고 특정 기능을 호출하지 않아도됩니다. 나는 바른 것을 참조하고 있지 않길 바랄 뿐이다.
감사합니다.
의 중복 가능성 (http://stackoverflow.com/questions/5788499/jquery-iframe-load-event) –