HTML को शामिल करने के तरीके
- पिछला पृष्ठ कैलेंडर
- अगला पृष्ठ सूची तालिका
HTML में HTML शीर्षक को शामिल करने के लिए सीखें。
HTML
जोड़ने वाले HTML को .html फ़ाइल में सहेजें:
content.html
<a href="howto_google_maps.asp">Google Maps</a><br> <a href="howto_css_animate_buttons.asp">Animated Buttons</a><br> <a href="howto_css_modals.asp">Modal Boxes</a><br> <a href="howto_js_animate.asp">Animations</a><br> <a href="howto_js_progressbar.asp">Progress Bars</a><br> <a href="howto_css_dropdown.asp">Hover Dropdowns</a><br> <a href="howto_js_dropdown.asp">Click Dropdowns</a><br> <a href="howto_css_table_responsive.asp">Responsive Tables</a><br>
HTML को समाहित करें
इस्तेमाल करें w3-include-html
गुण के द्वारा HTML को समाहित करें:
उदाहरण
<div w3-include-html="content.html"></div>
जावास्क्रिप्ट जोड़ें
HTML समाहित जावास्क्रिप्ट द्वारा पूरा किया जाता है。
उदाहरण
<script> function includeHTML() { var z, i, elmnt, file, xhttp; /* सभी HTML एलेमेंट के समूह को दौरा करें:*/ z = document.getElementsByTagName("*"); for (i = 0; i < z.length; i++) { elmnt = z[i]; /* विशेष गुण वाले एलेमेंटों को खोजें:*/ file = elmnt.getAttribute("w3-include-html"); if (file) { /* अभियात्रा गुण के माध्यम से फ़ाइल के रूप में HTTP अनुरोध करें:*/ xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4) { if (this.status == 200) {elmnt.innerHTML = this.responseText;} if (this.status == 404) {elmnt.innerHTML = "Page not found.";} /* अभियात्रा अधिसूचना हटाएं और फिर इस फ़ंक्शन को फिर से आमंत्रित करें:*/ elmnt.removeAttribute("w3-include-html"); includeHTML(); } } xhttp.open("GET", file, true); xhttp.send(); /* फ़ंक्शन छोड़ें:*/ return; } } } </script>
पृष्ठ के नीचे आमंत्रित करें includeHTML()
:
उदाहरण
<script> includeHTML(); </script>
अनेक HTML खण्डों को समाहित करना
आप अबतक कितने भी HTML खण्डों को समाहित कर सकते हैं:
उदाहरण
<div w3-include-html="h1.html"></div> <div w3-include-html="content.html"></div>
- पिछला पृष्ठ कैलेंडर
- अगला पृष्ठ सूची तालिका