Development| HTML| JavaScript| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JavaScript duplicate method 
 

JavaScript's duplicate method creates a duplicate copy of the specified text range.

 

JavaScript duplicate method

                         

JavaScript's duplicate method creates a duplicate copy of the specified text range. In this example code we have called the duplicate method on the text range object to create a duplicate copy of that text and then it will be displayed through the alert() method. This method duplicate is applied to the "textrange". Syntax for using the duplicate method is as follows:

Syntax:

TextRangeObject.duplicate();

Description of code:

In this html page we have created a html page with the one text box and one button. When button is clicked it takes the value from the text box and on it creates the text range and thereafter we have called the duplicate() method on it. When button is clicked it calls the method duplicateFunc() method defined in the JavaScript.

 <html>
<body>
<script language="JavaScript">
function duplicateFunc() {
    var textValue = txt.createTextRange();
    if(textValue.duplicate().text==""){
       alert("No text to display");
    }
    else{
      alert(textValue.duplicate().text);
    }
}
</script>
<p align="center">&nbsp;</p>
<div style="background: #cf2255; width:'100%';" align="center">
  <font color="#ffffcc" size="12pt"><b>Duplicate Example</b></font></div>
  <center>
  <div style="background: #ffffcc; width:'100%';" align="center">
<input type="text" id="txt" value="" />
<br>
<button id="myButton" onclick="duplicateFunc();">Call Duplicate</button>
</div>
  </center>
</body>
</html>

Output:

Enter some text into the text box and click on the "Call Duplicate" button.

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
Software Solutions
Least Viewed
Most Rated
Recently Viewed
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.