एचटीएमएल संदर्भ

वर्णमाला द्वारा HTML श्रेणी के अनुसार HTML एचटीएमएल ब्राउज़र समर्थन एचटीएमएल गुण HTML वैश्विक गुण एचटीएमएल घटनाक्रम एचटीएमएल रंग एचटीएमएल कैनवास एचटीएमएल ऑडियो/वीडियो एचटीएमएल कैरेक्टर सेट एचटीएमएल सिद्धांत एचटीएमएल यूआरएल एनकोड एचटीएमएल भाषा कोड एचटीएमएल देश कोड HTTP संदेश HTTP तरीके पीएक्स से ईएम कन्वर्टर कुंजीपटल अल्प मार्ग


एचटीएमएल <स्क्रिप्ट> टैग


उदाहरण

"हैलो जावास्क्रिप्ट!" लिखें। जावास्क्रिप्ट के साथ:

<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>

परिभाषा और उपयोग

टैग का <script>उपयोग क्लाइंट-साइड स्क्रिप्ट (जावास्क्रिप्ट) को एम्बेड करने के लिए किया जाता है।

<script>तत्व में या तो स्क्रिप्टिंग स्टेटमेंट होते हैं, या यह src विशेषता के माध्यम से बाहरी स्क्रिप्ट फ़ाइल को इंगित करता है

जावास्क्रिप्ट के लिए सामान्य उपयोग छवि हेरफेर, प्रपत्र सत्यापन और सामग्री के गतिशील परिवर्तन हैं।


टिप्स और नोट्स

युक्ति: उन उपयोगकर्ताओं के लिए <noscript> तत्व भी देखें , जिनके ब्राउज़र में स्क्रिप्ट अक्षम हैं, या जिनके पास क्लाइंट-साइड स्क्रिप्टिंग का समर्थन नहीं करने वाला ब्राउज़र है।

युक्ति: यदि आप जावास्क्रिप्ट के बारे में अधिक जानना चाहते हैं, तो हमारे जावास्क्रिप्ट ट्यूटोरियल पर जाएँ ।


ब्राउज़र समर्थन

Element
<script> Yes Yes Yes Yes Yes


गुण

Attribute Value Description
async async Specifies that the script is downloaded in parallel to parsing the page, and executed as soon as it is available (before parsing completes) (only for external scripts)
crossorigin anonymous
use-credentials
Sets the mode of the request to an HTTP CORS Request
defer defer Specifies that the script is downloaded in parallel to parsing the page, and executed after the page has finished parsing (only for external scripts)
integrity filehash Allows a browser to check the fetched script to ensure that the code is never loaded if the source has been manipulated
nomodule True
False
Specifies that the script should not be executed in browsers supporting ES2015 modules
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin
strict-origin-when-cross-origin
unsafe-url
Specifies which referrer information to send when fetching a script
src URL Specifies the URL of an external script file
type scripttype Specifies the media type of the script

एचटीएमएल और एक्सएचटीएमएल के बीच अंतर

XHTML में, स्क्रिप्ट के अंदर की सामग्री को #PCDATA (CDATA के बजाय) के रूप में घोषित किया जाता है, जिसका अर्थ है कि संस्थाओं को पार्स किया जाएगा।

इसका मतलब है कि एक्सएचटीएमएल में, सभी विशेष वर्णों को एन्कोड किया जाना चाहिए, या सभी सामग्री को सीडीएटीए अनुभाग के अंदर लपेटा जाना चाहिए:

<script type="text/javascript">
//<![CDATA[
var i = 10;
if (i < 5) {
  // some code
}
//]]>
</script>

वैश्विक गुण

<script>टैग HTML में वैश्विक विशेषताओं का भी समर्थन करता है


संबंधित पृष्ठ

HTML ट्यूटोरियल: HTML स्क्रिप्ट्स

HTML DOM संदर्भ: स्क्रिप्ट ऑब्जेक्ट

जावास्क्रिप्ट ट्यूटोरियल: जावास्क्रिप्ट सीखें


डिफ़ॉल्ट सीएसएस सेटिंग्स

अधिकांश ब्राउज़र <script>निम्न डिफ़ॉल्ट मानों के साथ तत्व प्रदर्शित करेंगे:

script {
  display: none;
}