All Tech Tips

protocol Property

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. .

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


Copyright © 2006 alltechtips.com. All rights reserved.

This website and the materials and information you find on this website are provided "as is", without warranty of any kind, either express or implied, including without limitation any warranty for information, services, or products provided through or in connection with the service and any implied warranties of merchantability, fitness for a particular purpose, expectation of privacy or non-infringement.