Link type गुण लिंक किए गए दस्तावेज़ के प्रकार को सेट/लौटाता है।
सिंटैक्स
निम्नलिखित सिंटैक्स है −
- type विशेषता का मान लौटाना
linkObject.type
- type को वैध मान पर सेट करना
linkObject.type = value
नोट − वैध मानों में "text/javascript", "text/css", "image/gif", आदि शामिल हैं।
उदाहरण
आइए Link type गुण का एक उदाहरण देखें −
<!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="प्रकार सुधारें" onclick="correctType()"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var extStyle = document.getElementById("extStyle"); divDisplay.textContent = 'लिंक किए गए दस्तावेज़ का प्रकार: '+extStyle.type+' संगत नहीं है'; function correctType(){ extStyle.type = 'text/css'; divDisplay.textContent = 'बधाई! लिंक किए गए दस्तावेज़ का प्रकार: '+extStyle.type+' संगत है'; } </script> </body> </html>
उपरोक्त उदाहरण में ‘style.css' में शामिल है −
form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; }
आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा −
'प्रकार सुधारें' बटन पर क्लिक करने से पहले −

'प्रकार सुधारें' बटन पर क्लिक करने के बाद −
