protocol

HTML (DHTML)

protocol Property

Internet Development Index

Sets or retrieves the protocol portion of a URL.

Syntax

HTMLN/A
Scriptingobject.protocol [ = sProtocol ]

Possible Values

sProtocolString that specifies or receives the protocol used to transfer information.

The property is read/write. The property has no default value.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.

Remarks

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

The document, img, and location objects expose the protocol property as read-only. 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.

Example

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

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

Standards Information

There is no public standard that applies to this property.

Applies To

A, AREA, document, IMG, location