2011. 12. 5. 17:42
반응형
frame은 ready() 로 처리해도 안되고.. load () 로 해야된다.
아래 예제..
frame 안의 접근은 $(this.contentDocument). 로 해야 된다는것..


<html>
    <head>
        <title>jQuery and Frames</title>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            jQuery( function() {
                $('#frame1').load( function(){
                    $(this.contentDocument).find('body').html('This frame was modified with jQuery! Yay!!!')
                });
                $('#frame2').load( function(){
                    $(this.contentDocument).find('body').html('This frame was modified with jQuery! Yay!!!')
                });
            });
        </script>
    </head>
    <body>
        <h2>jQuery and Frames</h2>
         
        <h4>Frame from the <i>same</i> domain as parent.</h4>
        <iframe id="frame1" src="iframe.html"></iframe>
         
        <h4>Frame from a <i>different</i> domain as parent.</h4>
        <iframe id="frame2" src="http://lifeinnovative.com/frame_for_liveintensely_demo.html"></iframe>
    </body>
</html>
반응형

'Front-Html > Jquery' 카테고리의 다른 글

셀렉터 추가 제거 이전 선택 처리  (0) 2014.02.19
jquery $를 다른것으로 바꿔서 사용  (2) 2011.12.14
jQuery로 select box tag Control  (1) 2011.10.27
iframe 높이 자동 조절  (1) 2011.10.19
jquery cookie plugin  (2) 2010.12.30
Posted by seongsland