Share via


protocol property

Sets or retrieves the protocol portion of a URL.

Syntax

JavaScript

p = object.protocol

 

Property values

Type: String

the protocol used to transfer information.

Remarks

The document, img, and location objects expose the protocol property as read-only. The location.protocol property returns the initial substring of a URL, including the first colon (for example, HTTP:). However, document.protocol returns the expanded text of the protocol acronym. For example, it returns the http protocol as Hypertext Transfer Protocol.

The protocol property specifies how to transfer information from the host to the client. Windows Internet Explorer supports several predefined protocols, including http and ftp.

Examples

This example function returns the protocol property of the current document location.

function getProtocol()
{
    return document.location.protocol;
}

See also

a

area

document

img

location