The HTML DOM Anchor origin property returns the protocol, hostname and port number of the href attribute value, for example, https://www.demo.com:6064 Following is the syntax−anchorObj.originLet us now see an example to implement the DOM Anchor origin property −Example Live Demo
Company
Products
Display href Part
Display origin
Display hreflang
function display() {
var a = document.getElementById("mylink").href;
document.getElementById("myid").innerHTML = a;
}
function display2() {
var a = document.getElementById("mylink").origin;
document.getElementById("myid").innerHTML = a;
}
function display3() {
var a = document.getElementById("mylink").hreflang;
document.getElementById("myid").innerHTML = a;
}
OutputClick on the “Display origin” button−
The form attribute of the element is used to specify the forms wherein the button belongs to.Following is the syntax −The id above is the if of the form wherein the button belongs to.Let us now see an example to implement the form attribute of the element−Example Live Demo Points Player: Rank: Points: Click to Submit This will produce the following output. The button is part of the form−In the above example, we have set a form and added form elements− ... Read More
The HTML DOM Anchor href property is used to set or return the href attribute. It returns the url of the link.Following is the syntax to set the anchor href property−anchorObj.href = URLAbove, URL is the url of the link. It can be an absolute, relative or anchor link with a hash.Following is the syntax to return the anchor href property−anchorObj.hrefLet us now see an example to implement the DOM Anchor href property−Example Live Demo Company Our Team Display href Part Display Host Part Display Hostname function display() { var a = document.getElementById("mylink").href; ... Read More