My Name is Kay....

DIY , 먹방 , 개발 , 육아 , 여행 좋아합니다.
AdBlock 사용시 화면이 정상적으로 노출되지 않습니다.
포스팅 관련 문의 및 개발 문의는 Email : wkzkfmxksi@gmail.com

추가 포스팅이 이뤄지지 않는 블로그입니다. 문의는 wkzkfmxksi@gmail.com 으로 연락주세요.
kay
조회 수 105557 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

* 크로스 도메인 iFrame Resize 플러그인


* Plugin Url : http://www.jqueryscript.net/layout/jQuery-Plugin-For-Auto-Resizing-iFrame-iFrame-Resizer.html


iFrame 사용시 Height Resize 문제가 가장 어려웠습니다만..

이론상으로 참고할 만한 블로그는 http://johan.driessen.se/posts/resizing-cross-domain-iframes 를 ...

쉽게 생각하면 아래 이미지 한컷으로 정리가 될것입니다.


Cross Domain Iframe Resize.PNG


구현 시 편의를 위해 Jquery plugin을 소개합니다.



* 부모창(index.html)


<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8"> 
<title>iFrame message passing test</title> 
<meta name="description" content="iFrame message passing test"> 
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head> 
<body> 
 
<h2>Automagically resizing iFrame</h2>
<p>Resize window or click 'Toggle content' to watch iFrame resize</p>
<div style="margin:20px;">
<iframe src="frame.content.html" width="100%" scrolling="no"></iframe>
</div>
<p id="callback">
</p>
 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.iframeResizer.min.js"></script> 
<script type="text/javascript">
$('iframe').iFrameSizer({
     log                    : true,  // For development
     autoResize             : true,  // Trigering resize on events in iFrame
     contentWindowBodyMargin: 8,     // Set the default browser body margin style (in px)
     doHeight               : true,  // Calculates dynamic height
     doWidth                : false, // Calculates dynamic width
     enablePublicMethods    : true,  // Enable methods within iframe hosted page 
     interval               : 0,     // interval in ms to recalculate body height, 0 to disable refreshing
     scrolling              : false, // Enable the scrollbars in the iFrame
     callback               : function(messageData){ // Callback fn when message is received
          $('p#callback').html(
               '<b>Frame ID:</b> '    + messageData.iframe.id +
               ' <b>Height:</b> '     + messageData.height +
               ' <b>Width:</b> '      + messageData.width + 
               ' <b>Event type:</b> ' + messageData.type
          );
     }
});
</script>
</body> 
</html>



* 자식창(frame.content.html)


<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>iFrame message passing test</title>
		<meta name="description" content="iFrame message passing test">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
		<style>
			a { float:right; margin-left:10px;}
		</style>
	</head>
	<body>

		<b>iFrame</b>
		<a href='#' onclick="$('p:eq(0)').toggle();return false;">Toggle content</a>
		 
		<a href='#' onclick="if ('parentIFrame' in window) window.parentIFrame.size(250);return false;">Size(250)</a>
		 
		<a href='#' onclick="if ('parentIFrame' in window)  window.parentIFrame.close();return false;">Close</a>

		<p>
			Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
		</p>
		<p>
			But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?
		</p>
		<p>
			On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.
		</p>


		<script type="text/javascript" src="iframeResizer.contentWindow.min.js"></script>
	</body>
</html>



참고 Url : http://www.goodkiss.co.kr/jQuery/2064

TAG •
?

  1. 특정 객체가 화면에 보이는지 여부 확인

    Date2015.12.14 CategoryUI Bykay Views4890
    Read More
  2. jQuery Formatnumber , 콤마처리

    Date2015.11.03 CategoryPlugIn Bykay Views2095
    Read More
  3. Select Box Option 동적 추가 , 삭제 , 복사

    Date2015.09.18 CategoryUI Bykay Views7081
    Read More
  4. FadeIn , FadeOut 을 이용한 간단한 메인 배너 이미지 노출.

    Date2014.10.23 Categoryetc Bykay Views2999
    Read More
  5. 기본값 가져오기 get default value

    Date2014.10.19 Categoryetc Bykay Views2323
    Read More
  6. woothemes FlexSlider - 슬라이더

    Date2014.09.16 CategoryUI Bykay Views286695
    Read More
  7. jQuery Org Chart - 조직도 그리기

    Date2014.09.01 CategoryPlugIn Bykay Views16611
    Read More
  8. Jquery Slider Bar / 슬라이더 바 3종 샘플

    Date2014.07.28 CategoryUI Bykay Views6713
    Read More
  9. 페이지 또는 객체에서 특정 키워드 강조하기

    Date2014.06.14 Categoryetc Bykay Views2716
    Read More
  10. Star Rating Plugin - jQuery 별점 주기

    Date2014.05.01 CategoryPlugIn Bykay Views13221
    Read More
  11. jQuery Plugin For Auto Resizing iFrame - iFrame Resizer

    Date2014.03.10 CategoryPlugIn Bykay Views105557
    Read More
  12. 우클릭 , 셀 선택 , 드래그 방지 스크립트

    Date2014.02.17 Categoryetc Bykay Views7916
    Read More
  13. Jquery Load 유무 체크하기

    Date2014.02.12 Categoryetc Bykay Views4287
    Read More
  14. jquery-syaku.rolling 상하좌우 롤링 ( 자동롤링 , 버튼 )

    Date2014.02.09 CategoryPlugIn Bykay Views20162
    Read More
  15. Table에 동적 Tr 추가/삭제 하기

    Date2014.02.09 Categoryetc Bykay Views21279
    Read More
  16. 한글/영어 byte 체크해서 자르기

    Date2013.11.30 Categoryetc Bykay Views9702
    Read More
  17. 동적으로 추가된 객체에 datepicker() 적용하기

    Date2013.11.06 CategoryUI Bykay Views10138
    Read More
  18. $.trim(str) trim...

    Date2013.10.16 Categoryetc Bykay Views3957
    Read More
  19. Jquery 로 defaultValue 읽어오기

    Date2013.10.03 CategoryA to Z Bykay Views3754
    Read More
  20. readonly , disabled 지정하기

    Date2013.10.01 CategoryA to Z Bykay Views4109
    Read More
Board Pagination Prev 1 2 3 Next
/ 3