I’m learning Javascript and again I have a question. As document.write(location.protocol); outputs the protocol used to send and receive data, something like http, https or something like that, but I’m placing a file on the desktop and opening it using the browser. So in the address bar it is showing me something like this:
file:///C:/Users/malik/Desktop/display.html
//when i use
document.write(location.protocol);
//it outputs
//file:
I want to ask is (‘file:’) any protocol, if yes then which one?
The
file:protocol isn’t a real TCP/IP protocol, it’s a virtual protocol used by browsers to specify a resource that is read from the local disk rather than over a TCP/IP connecction.Ref: List of TCP/IP protocols
Different browsers may use the
file:prefix in different ways.Internet Explorer implementation