Development| HTML| JavaScript| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
JavaScript getData method 
 

JavaScript method getData is used to get data in the specified format from the clipboard either via dataTransfer object or via the clipboardData object.

 

JavaScript getData method

                         

JavaScript method getData is used to get data in the specified format from the clipboard either via dataTransfer object or via the clipboardData object. It returns the data in the format retrieved from the clipboard through the dataTransfer object or the clipboardData object which is totally based on the setData.

 

 

 

 

 

Syntax: 

   Object.getData("DataFormat");

Where "DataFormat" may be either "Text" or "URL". If it is "Text" then it gets the data formatted as text and if it is "URL" then it gets the data formatted as a URL.

Description of code:

In our example code we have created two functions for copying data and pasting data to the described text area. These two functions copyData() and pasteData() is called when user clicks on the buttons Copy and Paste. Before copying data we need to select the data otherwise in the clipboardData object "null" value would be set and it will be further pasted to the text area. Here is the following html example code for getDataExample method as follows :

<html>
<script>
function copyData(){
clipboardData.setData('Text',document.selection.createRange().text);
}
function pasteData(){
txtArea.value = clipboardData.getData('Text');
}
</script>
<body>
<div style="background: #ff9900; width:'100%';" align="center">
<font color="#0000ff" size="12pt">
<b>Get Data Example</b>
</font>
</div>
<center>
</br>
<div style="background: #0099ff; width:'100%';" align="center">
<p>Rose India Technologies Pvt. Ltd. is a global services company that ensures maximum returns by providing quality software solutions and services. The Indian based company provides services to several reputed institutional clients, in the domain of IT and IT enabled Technologies. We help in understanding the client requirements and offer customized solutions in various specialized areas like Web based Technologies, Database Systems, Client Server Architecture, E-commerce Solutions and Consultancy Services</p>
</div>
<textarea id="txtArea" style="width:600; height:100; background:#ffffcc;">
Paste your text here....
</textarea>
<hr>
<button onclick="copyData();">Copy</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button onclick="pasteData();">Paste</button>
</center>
</body>
</html>

Output :

Select the data to which you want to copy.

Click on the Copy button to get data which is selected by you and now click on the Paste button to paste the copied text data to the text area.

You can also download the full source code from the provided link as given below.

Download Source Code

                         

» View all related tutorials
Related Tags: java javascript c attributes script reference object method sed remove ip attribute node move nat to ref e it alter

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.