diff options
Diffstat (limited to 'files/ko/web/api/datatransfer/getdata/index.html')
-rw-r--r-- | files/ko/web/api/datatransfer/getdata/index.html | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/files/ko/web/api/datatransfer/getdata/index.html b/files/ko/web/api/datatransfer/getdata/index.html new file mode 100644 index 0000000000..8a9edcf029 --- /dev/null +++ b/files/ko/web/api/datatransfer/getdata/index.html @@ -0,0 +1,112 @@ +--- +title: DataTransfer.getData() +slug: Web/API/DataTransfer/getData +tags: + - API + - HTML DOM + - Method + - Reference +translation_of: Web/API/DataTransfer/getData +--- +<div> +<p>{{APIRef("HTML DOM")}}</p> +</div> + +<p><strong><code>DataTransfer.getData()</code></strong> 메소드는 특정 형태를 위해 ({{domxref("DOMString")}}로) 끌어낸 데이터를 회수한다. 가령, 끌어내는 동작이 데이터를 포함하지 않는다면, 이 메소드는 빈 문자열을 반환한다.</p> + +<p>예시 데이터 형식으로는 <code>text/plain</code> 와 <code>text/uri-list </code>이 있다.</p> + +<h2 id="구문">구문</h2> + +<pre class="syntaxbox"><var>dataTransfer</var>.getData(<em>format</em>); +</pre> + +<h3 id="매개변수">매개변수</h3> + +<dl> + <dt><code><em>format</em></code></dt> + <dd>회수할 데이터 형식을 나타내는 {{domxref("DOMString")}}</dd> +</dl> + +<h3 id="반환_값">반환 값</h3> + +<dl> + <dt>{{domxref("DOMString")}}</dt> + <dd>특정 <code>format</code>을 위해 끌어낸 데이터를 나타내는 {{domxref("DOMString")}}. 만약 끌어내는 동작이 데이터를 가지고 있지 않거나 동작이 특정 <code>format</code> 에 대한 데이터를 가지고 있지 않다면, 이 메소드는 빈 문자열을 반환한다.</dd> +</dl> + +<h2 id="예제">예제</h2> + +<p>이 예시는 {{domxref("DataTransfer")}} 객체의 {{domxref("DataTransfer.getData()","getData()")}} 와 {{domxref("DataTransfer.setData()","setData()")}} 메소드의 사용을 보여준다.</p> + +<h3 id="HTML_내용">HTML 내용</h3> + +<pre class="brush: html"><div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"> + <span id="drag" draggable="true" ondragstart="drag(event)">drag me to the other box</span> +</div> +<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div> +</pre> + +<h3 id="CSS_내용">CSS 내용</h3> + +<pre class="brush: css">#div1, #div2 { + width:100px; + height:50px; + padding:10px; + border:1px solid #aaaaaa; +} +</pre> + +<h3 id="JavaScript_내용">JavaScript 내용</h3> + +<pre class="brush: js">function allowDrop(allowdropevent) { + allowdropevent.target.style.color = 'blue'; + allowdropevent.preventDefault(); +} + +function drag(dragevent) { + dragevent.dataTransfer.setData("text", dragevent.target.id); + dragevent.target.style.color = 'green'; +} + +function drop(dropevent) { + dropevent.preventDefault(); + var data = dropevent.dataTransfer.getData("text"); + dropevent.target.appendChild(document.getElementById(data)); + document.getElementById("drag").style.color = 'black'; +} +</pre> + +<h3 id="결과">결과</h3> + +<p id="EmbedLiveSample('Example'_''_''_''_'WebAPIDataTransfergetData')">{{ EmbedLiveSample('예제', 600) }}</p> + +<h2 id="명세">명세</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">명세</th> + <th scope="col">상태</th> + <th scope="col">비고</th> + </tr> + <tr> + <td>{{SpecName("HTML WHATWG", "interaction.html#dom-datatransfer-getdata", "getData()")}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName("HTML5.1", "editing.html#dom-datatransfer-getdata", "getData()")}}</td> + <td>{{Spec2("HTML5.1")}}</td> + <td>첫 정의</td> + </tr> + </tbody> +</table> + +<h2 id="브라우저_호환성">브라우저 호환성</h2> + +<p>{{Compat("api.DataTransfer.getData")}}</p> + +<h2 id="같이_보기">같이 보기</h2> + +<p>{{page("/en-US/docs/Web/API/DataTransfer", "See also")}}</p> |