Window location.href
ဥပမာများ
လက်ရှိစာမျက်နှာ၏ URL ကို ရယူပါ-
let url = location.href;
လက်ရှိစာမျက်နှာ၏ URL ကို သတ်မှတ်ပါ-
location.href = "https://www.w3schools.com";
အောက်တွင် နောက်ထပ် ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
ပိုင်ဆိုင်မှုသည် လက်ရှိ location.href
စာမျက်နှာ၏ URL တစ်ခုလုံးကို သတ်မှတ် သို့မဟုတ် ပြန်ပေးသည်။
အထားအသို
href ပိုင်ဆိုင်မှုကို ပြန်ပေးပါ-
location.href
href ပိုင်ဆိုင်မှုကို သတ်မှတ်ပါ-
location.href = URL
အိမ်ခြံမြေတန်ဖိုး
Parameter | Description |
URL |
An absolute URL like: http://www.example.com/default.htm A relative URL like default.htm An anchor URL like location.href="#top" A new protocol like: ftp://someftpserver.com mailto:[email protected] file://host/path/example.txt |
တန်ဖိုးကို ပြန်ပေးသည်။
ရိုက်ပါ။ | ဖော်ပြချက် |
ကြိုးတစ်ချောင်း | ပရိုတိုကော (https:// ကဲ့သို့) အပါအဝင် စာမျက်နှာ၏ URL အပြည့်အစုံ။ |
နောက်ထပ် ဥပမာများ
စာမျက်နှာတစ်ခုအတွင်း ကျောက်ဆူးတစ်ခုသို့ ညွှန်ပြရန် href တန်ဖိုးကို သတ်မှတ်ပါ-
location.href = "#top";
အီးမေးလ်လိပ်စာတစ်ခုသို့ညွှန်ပြရန် href တန်ဖိုးကို သတ်မှတ်ပါ (ဖွင့်ပြီး အီးမေးလ်စာအသစ်တစ်ခု ဖန်တီးပါမည်-
location.href = "mailto:[email protected]";
Browser ပံ့ပိုးမှု
location.href
ဘရောက်ဆာအားလုံးတွင် ထောက်ခံသည်-
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |