• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » JScript » String » JavaScript String anchor() Method
Next →
← Prev

JavaScript String anchor() Method

By Dinesh Thakur

The JavaScript Anchor is a string function that can be accessed using dot operator with string variable. It transforms the specified text into hypertext.

The JavaScript Anchor object is a place in a document that is the target of a hypertext link. It is the property of the document object. The JavaScript Anchor() method takes a parameter that will be the name attribute for the named anchor. Basically, it creates an HTML tag set with the following syntax:

<a name=" locationOrURL "> anchorName </a> 

Where location Or URL refers to a URL or destination anchor. anchorName indicates the anchor name that is the target for a hypertext.  For example, take a look at this code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> 
<title>JavaScript Anchor() method </title> 
</head> 
<body> 
  <h1 style="color: blue">JavaScript anchor() method</h1> <hr /> 
  <script type="text/javascript"> 
  var locationOrURL = " http://ecomputernotes.com"; 
  var anchorName = locationOrURL.anchor("Computer Notes");  
  alert(anchorName); 
</script> 
</body> 
</html> 

Here, you assign a string literal to the variable location Or URL. You then call the anchor() method with a parameter of “Computer Notes” from the string literal. The result is assigned to the anchorName variable. The value of the anchorName variable is then written on the page. JavaScript Anchor()  method returns the string embedded in the <a> tag, like this:

JavaScript anchor()

You’ll also like:

  1. JavaScript String substring() Method
  2. JavaScript String substr() Method
  3. JavaScript String search() Method
  4. JavaScript String match() Method
  5. JavaScript String replace() Method
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

JavaScript Tutorials

JavaScript Tutorials

  • JavaScript - Home
  • JavaScript - Operators
  • JavaScript - Comments
  • JavaScript - If...Else
  • JavaScript - For Loop
  • JavaScript - Popup Boxes
  • JavaScript - Switch Statement
  • JavaScript - while Loop
  • JavaScript - Functions
  • JavaScript - Variables
  • JavaScript - Statements
  • JavaScript - Substring()
  • JavaScript - indexOf()
  • JavaScript - Match()
  • JavaScript - Replace()
  • JavaScript - Search()
  • JavaScript - Split()
  • JavaScript - Substr()
  • JavaScript - Blink()
  • JavaScript - Anchor()
  • JavaScript - Big()
  • JavaScript - Strings Object
  • JavaScript - String Format
  • JavaScript - Length Property
  • JavaScript - Prototype
  • JavaScript - Slice Substr Vs Substring
  • JavaScript - JavaScript:void(0)

Other Links

  • JavaScript - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW