Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Link Object
The HTML DOM Link Object in HTML represents the <link> element.
Syntax
Following is the syntax −
Creating a <link> element
var linkObject = document.createElement(“LINK”)
properties
Here, “LinkObject” can have the following properties −
| Property | Description |
|---|---|
| crossOrigin | It sets/returns the the CORS settings of the linked document |
| disabled | It sets/returns whether the linked document is disabled, or not |
| href | It sets/returns the URL of the linked document |
| hreflang | It sets/returns the language code of the linked document |
| media | It sets/returns the media type for the link element tag |
| rel | It sets/returns the relationship between the current and the linked document |
| sizes | It returns the value of the sizes attribute of the linked document |
| type | It sets/returns the content type of the linked document |
Example
Let us see an example for Link disabled property −
<!DOCTYPE html>
<html>
<head>
<title>Link Disabled</title>
<link id="extStyle" rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form>
<fieldset>
<legend>Link-disabled</legend>
<label for="WeekSelect">Sales Target Week:
<input type="week" id="WeekSelect" value="2020-W13" disabled>
</label>
<input type="button" onclick="enableWeekInput()" value="Change Sales Target Week">
<input type="button" onclick="beautify()" value="Disable Styling">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputWeek = document.getElementById("WeekSelect");
var extStyle = document.getElementById("extStyle");
divDisplay.textContent = 'Week Input disabled: '+inputWeek.disabled;
function enableWeekInput() {
inputWeek.disabled = false;
divDisplay.textContent = 'Week Input disabled: '+inputWeek.disabled;
}
function beautify(){
extStyle.disabled = true;
}
</script>
</body>
</html>
In the above example ‘style.css’ contains −
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
Output
This will produce the following output −
Before clicking ‘Disable Styling’ button −

After clicking ‘Disable Styling’ button −

Advertisements