लिंक प्रकार की संपत्ति लिंक किए गए दस्तावेज़ के प्रकार को सेट/रिटर्न करती है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
- लौटना प्रकार विशेषता मान
linkObject.type
- सेटिंग प्रकार मान्य मान के लिए
linkObject.type = value
नोट - मान्य मानों में "टेक्स्ट/जावास्क्रिप्ट", "टेक्स्ट/सीएसएस", "इमेज/जीआईएफ", आदि शामिल हैं।
उदाहरण
आइए लिंक प्रकार . के लिए एक उदाहरण देखें संपत्ति -
<!DOCTYPE html>
<html>
<head>
<title>Link type</title>
<link id="extStyle" rel="stylesheet" href="style.css" type="myStyle">
</head>
<body>
<form>
<fieldset>
<legend>Link-type</legend>
<input type="button" value="Correct Type" onclick="correctType()">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
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';
}
</script>
</body>
</html> उपरोक्त उदाहरण में ‘style.css’ शामिल हैं -
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
} आउटपुट
यह निम्नलिखित आउटपुट देगा -
‘सही प्रकार’ clicking क्लिक करने से पहले बटन -

'सही प्रकार' पर क्लिक करने के बाद बटन -
