Anchor protocol Property

❮ Anchor Object

Example

Return the protocol of a link:

var x = document.getElementById("myAnchor").protocol;
Try it Yourself »

Description

The protocol property sets or returns the protocol part of the href attribute value.

The protocol is a standard that specifies how data are transmitted between computers.


Browser Support

Property
protocol Yes Yes Yes Yes Yes

Syntax

Return the protocol property:

anchorObject.protocol

Set the protocol property:

anchorObject.protocol = protocol

Property Values

Value Description
protocol Specifies the protocol of a URL. Possible Values:
  • file:
  • ftp:
  • http:
  • https:
  • mailto:
  • etc..


Technical Details

Return Value: A String, representing the protocol part of the URL, including the colon sign (:)

More Examples

Example

Change the protocol of a link:

document.getElementById("myAnchor").protocol = "mailto:";
Try it Yourself »

Related Pages

JavaScript reference: location.protocol Property


❮ Anchor Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.