- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2416 Articles for HTML
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
52 Views
The Location port property returns/sets the port number (if specified) for a URL. Port number might not get displayed if not explicitly specified.SyntaxFollowing is the syntax −Returning value of the port propertylocation.portValue of the port property setlocation.port = portNumberExampleLet us see an example for Location port property − Live Demo Location port form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
68 Views
The Location pathname property returns/sets the string corresponding to the URL pathname.SyntaxFollowing is the syntax −Returning value of the pathname propertylocation.pathnameValue of the href property setlocation.pathname = pathOfHostExampleLet us see an example for Location pathname property − Live Demo Location pathname form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } Location-pathname Current URL: var divDisplay = document.getElementById("divDisplay"); var urlSelect = document.getElementById("urlSelect"); function getpathname(){ divDisplay.textContent = 'URL pathname: '+location.pathname; } OutputThis will produce the following output −Before clicking ‘Get pathname’ button −After clicking ‘Get pathname’ button −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
65 Views
The Location origin property returns the string corresponding to the URL’s protocol, hostname, host port number (if specified).SyntaxFollowing is the syntax −Returning value of the origin propertylocation.originExampleLet us see an example for Location origin property − Live Demo Location origin form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } Location-origin Current URL: var divDisplay = document.getElementById("divDisplay"); var urlSelect = document.getElementById("urlSelect"); function getorigin(){ divDisplay.textContent = 'URL Origin: '+location.origin; } OutputThis will produce the following output −Before clicking ‘Get origin’ button −After clicking ‘Get origin’ button −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
92 Views
The HTML DOM Location href property returns/sets the string corresponding to the URL path.SyntaxFollowing is the syntax −Returning value of the href propertylocation.hrefValue of the href property setlocation.href = hrefExampleLet us see an example for Location href property − Live Demo Location href form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } Location-href Current URL: var divDisplay = document.getElementById("divDisplay"); var urlSelect = document.getElementById("urlSelect"); function gethref(){ divDisplay.textContent = 'URL Path: '+location.href; } OutputThis will produce the following output −Before clicking ‘Get href’ button −After clicking ‘Get href’ button −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
269 Views
The Location hostname property returns/sets the hostname for the URL path.SyntaxFollowing is the syntax −Returning value of the hostname propertylocation.hostnameValue of the hostname property setlocation.hostname = hostnameExampleLet us see an example for Location hostname property − Live Demo Location hostname form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } Location-hostname Current URL: var divDisplay = document.getElementById("divDisplay"); var urlSelect = document.getElementById("urlSelect"); function getHostname(){ divDisplay.textContent = 'Hostname: '+location.hostname; } OutputThis will produce the following output −Before clicking ‘Get Hostname’ button −After clicking ‘Get Hostname’ button −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
67 Views
The Location host property returns/sets the hostname and host port (if specified). Port might not get displayed if not explicitly specified.SyntaxFollowing is the syntax −Returning value of the host propertylocation.hostValue of the host property setlocation.host = hostname:hostExampleLet us see an example for Location host property − Live Demo Location host form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } Location-host Current URL: ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
142 Views
The Location hash property returns/appends a string value (anchor part) to a URL. Anchor part is prefixed with ‘#’ automatically and then appended.SyntaxFollowing is the syntax −Returning value of the hash propertylocation.hashValue of the hash property setlocation.hash = ‘string’ExampleLet us see an example for Location hash property − Live Demo Location hash form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
206 Views
The HTML DOM Local Storage clear() method is used for clearing the whole local storage entries.SyntaxFollowing is the syntax −localStorage.clear()OrsessionStorage.clear()ExampleLet us see an example for LocalStorage() method property − Live Demo LocalStorage clear() form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } table, th, td { border:1px solid black; border-collapse: collapse; margin: 0 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
133 Views
The links Collection returns a list/collection of all the links corresponding to and/or elements.SyntaxFollowing is the syntax −Returning links collectiondocument.linksPropertiesHere, “links” collection can have the following properties and methods −Property/MethodDescriptionlengthIt returns the number of and elementsnamedItem()It returns the or/and element with the specified idExampleLet us see an example for links collection length property − Live Demo Links Collection length form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
85 Views
The Link type property sets/returns the type of a linked document.SyntaxFollowing is the syntax −Returning type attribute valuelinkObject.typeSetting type to a valid valuelinkObject.type = valueNOTE − valid values include "text/javascript", "text/css", "image/gif", etc.ExampleLet us see an example for Link type property − Link type Link-type var divDisplay = document.getElementById("divDisplay"); var extStyle = document.getElementById("extStyle"); divDisplay.textContent = 'The linked document type: '+extStyle.type+' is not compatible'; function correctType(){ extStyle.type = 'text/css'; divDisplay.textContent = 'Congrats! The linked document type: '+extStyle.type+' is compatible'; ... Read More