HTML <script> Tag
ဥပမာ
"Hello JavaScript!" ရေးပါ။ JavaScript ဖြင့်
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
တဂ် ကို <script>
client-side script (JavaScript) တွင် ထည့်သွင်းရန် အသုံးပြုသည်။
ဒြပ်စင်တွင် Scripting Statement ပါ၀င် သည် <script>
သို့မဟုတ် ၎င်းသည် src ရည်ညွှန်းချက်မှတစ်ဆင့် ပြင်ပ script ဖိုင်ကိုညွှန်ပြသည်။
JavaScript အတွက် အသုံးများသော အသုံးပြုမှုများမှာ ရုပ်ပုံ ခြယ်လှယ်ခြင်း၊ ဖောင်ပုံစံ အတည်ပြုခြင်းနှင့် အကြောင်းအရာ၏ တက်ကြွသော အပြောင်းအလဲများ ဖြစ်သည်။
အကြံပြုချက်များနှင့် မှတ်စုများ
အကြံပြုချက်- ၎င်းတို့၏ဘရောက်ဆာတွင် scripts များကိုပိတ်ထားသောအသုံးပြုသူများအတွက်၊ သို့မဟုတ် client-side scripting ကိုမပံ့ပိုးသောဘရောက်ဆာ တစ်ခုရှိသည် ကိုလည်းကြည့်ရှုပါ ။
အကြံပြုချက်- JavaScript အကြောင်း ပိုမိုလေ့လာလိုပါက၊ ကျွန်ုပ်တို့၏ JavaScript Tutorial သို့ ဝင်ရောက်ကြည့်ရှု ပါ။
Browser ပံ့ပိုးမှု
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 |
HTML နှင့် XHTML ကွာခြားချက်များ
XHTML တွင်၊ scripts များအတွင်းရှိအကြောင်းအရာကို #PCDATA (CDATA အစား) အဖြစ်ကြေငြာထားသည်၊ ဆိုလိုသည်မှာ အကြောင်းအရာများကိုခွဲခြမ်းစိတ်ဖြာမည်ဖြစ်သည်။
ဆိုလိုသည်မှာ XHTML တွင် အထူးအက္ခရာများအားလုံးကို ကုဒ်လုပ်ထားသင့်သည်၊ သို့မဟုတ် အကြောင်းအရာအားလုံးကို CDATA ကဏ္ဍအတွင်းတွင် ထည့်သွင်းထားသင့်သည်-
<script type="text/javascript">
//<![CDATA[
var i = 10;
if (i < 5) {
// some code
}
//]]>
</script>
ကမ္ဘာလုံးဆိုင်ရာ အရည်အချင်းများ
<script>
tag သည် HTML တွင် Global Attributes ကို ပံ့ပိုး ပေးပါသည်။
ဆက်စပ်စာမျက်နှာများ
HTML သင်ခန်းစာ- HTML Scripts
HTML DOM ရည်ညွှန်းချက်- Script Object
JavaScript ကျူတိုရီရယ်- JavaScript ကို လေ့လာပါ ။
မူရင်း CSS ဆက်တင်များ
ဘရောက်ဆာအများစုသည် <script>
အောက်ဖော်ပြပါ ပုံသေတန်ဖိုးများဖြင့် အစိတ်အပိုင်းကို ပြသလိမ့်မည်-
script {
display: none;
}