아이프레임 리사이즈 문제 해법

|

How To Resize an IFrame to the Size of Its Contents Without Displaying Scroll Bars

Article ID : 278469
Last Review : November 23, 2006
Revision : 4.1
This article was previously published under Q278469

SUMMARY

In certain situations, you may want to resize an IFrame so that all of its document contents are visible, but no scroll bars are displayed on the page. This article describes how to do this.

Back to the top

MORE INFORMATION

To determine the size of the IFrame's contents, you must access the height and width properties of the underlying IFrame document. Because you only have scripting access to pages that are hosted in the same domain, you can only access the properties to the pages that are hosted within the same domain (for example, Cross Frame Scripting). Therefore, the source document of the IFrame must be from the same domain as the page that contains the IFrame.

The following code demonstrates how to resize an IFrame in this way. Create a new .htm document, and paste the following HTML code. In the SRC attribute for the IFrame, you must supply an HTML page from the same domain that the IFrame loads.

NOTE: This technique may not work correctly if there are absolutely positioned elements that are residing within the IFrame.
<HTML>
<HEAD>
<SCRIPT LANGUAGE=javascript>
<!--
function reSize()
{
	try{	
	var oBody	=	ifrm.document.body;
	var oFrame	=	document.all("ifrm");
		
	oFrame.style.height = oBody.scrollHeight + 
(oBody.offsetHeight - oBody.clientHeight); oFrame.style.width = oBody.scrollWidth +
(oBody.offsetWidth - oBody.clientWidth); } //An error is raised if the IFrame domain !=
its container's domain catch(e) { window.status = 'Error: ' + e.number + '; ' + e.description; } } //--> </SCRIPT> </HEAD> <BODY onload=reSize()> <iframe onresize=reSize() id=ifrm src=YOUR_PAGE_HERE></iframe> </BODY> </HTML>
This example uses try and catch to check for domain consistency, which are only available with Internet Explorer 5 and later. This error checking is included for illustration purposes and is not absolutely necessary; it only allows the script to fail gracefully.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:
https://partner.microsoft.com/global/30000104 (https://partner.microsoft.com/global/30000104)
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms)

Back to the top

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
167796 (http://support.microsoft.com/kb/167796/EN-US/) PRB: Permission Denied Error Message When Scripting Across Frame
For more information about measuring element dimensions and locations, see the following Microsoft Developer Network (MSDN) Web site:
http://msdn.microsoft.com/workshop/author/om/measuring.asp (http://msdn.microsoft.com/workshop/author/om/measuring.asp)
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
http://msdn.microsoft.com/ie/ (http://msdn.microsoft.com/ie/)

http://support.microsoft.com/iep (http://support.microsoft.com/iep)

Back to the top

And

멱등(Idempotent)

|

멱등은 동일한 작업을 어떤 부작용도 없이 한 번이고 두 번이고 계속해서 할 수 있다.

멱등이라는 말은 여러가지 의미로 사용된다. HTTP/서블릿 환경에서 이 말은 동일 요청은 서버에 어떤 잘못된 결과를 야기하지 않고 두 번이상 이루어질 수 있다는 의미이다. 동일 요청은 동일 응답을 가져야 한다는 의미가 아님을, 요청으로 어떤 부작용도 발생하지 말아야 한다는 의미가 아님을 유의해야 한다.

HTTP 스펙 1.1에서는 GET, HEAD, PUT은 멱등이라고 정의하고 있다. 물론 개발자가 멱등이 아닌 doGet()을 작성할 수도 있지만 권장되지는 않는다. POST는 HTTP 스펙 1.1에 의하면 멱등이 아니다.

HTTP GET은 말 그대로 무엇인가를 서버로부터 가져오는 것이지, 서버에 수정을 가하기 위한 것이 아니다. GET은 HTTP 스펙에 따르면 멱등 메소드이다. GET은 어떤 부작용(bad side effect)없이 여러 번 실행할 수 있다.

POST는 반대로 멱등 메소드가 아니다. POST로 전송되는 몸체의 정보는 트랜잭션을 위한 것이면, 이는 되돌릴 수 있는 성질의 것이 아니다. 이런 이유 때문에 doPost()를 구현할 때 유의해야 한다.

-HEAD FIRST Servlet & JSP

'작업노트 > JSP & Servlet' 카테고리의 다른 글

커스텀 태그 라이브러리 사용시  (0) 2008.10.09
스코프(Scope)  (0) 2007.11.19
[미해결] 이미지 태그 한글 파일명 경로 처리문제  (0) 2007.09.04
request.getSession()  (0) 2007.05.27
JspWriter  (0) 2007.05.27
And

Java API Map

|
사용자 삽입 이미지
And