কম্পিউটার টিউটোরিয়াল

HTML DOM Anchor type প্রোপার্টি

অ্যাঙ্কর ট্যাগের সাথে যুক্ত HTML DOM type প্রোপার্টি লিংকের type অ্যাট্রিবিউটের মান সেট বা পাওয়ার জন্য ব্যবহৃত হয়। এই অ্যাট্রিবিউট HTML 5-এ পরিচয় করানো হয়েছিল। এই অ্যাট্রিবিউট শুধু সাজেশনারের জন্য এবং বাধ্যতামূলক নয়। এতে একক MIME (Multipurpose Internet Mail Extensions) ভ্যালু টাইপ থাকে।

সিনট্যাক্স

নিচে সিনট্যাক্স দেওয়া হলো:

type প্রোপার্টি রিটার্ন করা:

anchorObject.type

type প্রোপার্টি সেট করা:

anchorObject.type = MIME-type

উদাহরণ

Anchor text প্রোপার্টির জন্য একটি উদাহরণ দেখি:

<!DOCTYPE html> <html> <body> <p><a id="Anchor" type="text/html" href="https://www.examplesite.com">example site</a></p> <p><a id="Anchor2" href="https://www.example.com">example</a></p> <p>Click the buttons to set and get the type attribute.</p> <button onclick="getType1()">GetType</button> <button onclick="setType2()">SetType</button> <p id="Type1"></p> <script>    function getType1() {       var x = document.getElementById("Anchor").type;       document.getElementById("Type1").innerHTML = x;    }    function setType2(){       document.getElementById("Type1").innerHTML="Type has been set";       document.getElementById("Anchor2").type="text/html";    } </script> </body> </html>

আউটপুট

এটি নিচের আউটপুট দেবে:

HTML DOM Anchor type প্রোপার্টি

GetType বাটনে ক্লিক করলে:

HTML DOM Anchor type প্রোপার্টি

SetType বাটনে ক্লিক করলে:

HTML DOM Anchor type প্রোপার্টি

উপরের উদাহরণে:

আমরা id Anchor এবং Anchor2 সহ দুটি লিংক নিয়েছি। Anchor1-এর সাথে MIME type text/html যুক্ত আছে যখন Anchor2-এর সাথে কোনো MIME type যুক্ত নেই।

<p><a id="Anchor" type="text/html" href="https://www.examplesite.com">example site</a></p> <p><a id="Anchor2" href="https://www.example.com">example</a></p>

আমরা তারপর GetType এবং SetType নামে দুটি বাটন তৈরি করেছি যারা যথাক্রমে getType1() এবং getType2() ফাংশন এক্সিকিউট করবে।

<button onclick="getType1()">GetType</button> <button onclick="setType2()">SetType</button>

getType1() ফাংশন id "Anchor" সহ অ্যাঙ্কর ট্যাগের type রিটার্ন করে। setType2() ফাংশন id "Anchor2" সহ অ্যাঙ্কর ট্যাগের type text/html-এ সেট করে।

function getType1() {    var x = document.getElementById("Anchor").type;    document.getElementById("Type1").innerHTML = x; } function setType2(){    document.getElementById("Type1").innerHTML="Type has been set";    document.getElementById("Anchor2").type="text/html"; }

  1. HTML DOM Fieldset type প্রপার্টি

  2. HTML DOM Anchor hostname প্রোপার্টি: URL-এর হোস্টনেম পাওয়া

  3. HTML DOM Ol type প্রপার্টি

  4. HTML DOM Event type প্রপার্টি