JavaScript קיוינטו איסשנזוויסו אינך מקוון כונסי זינסוקו – ukwenza ngcono ukuxhumana kwewebhusayithi, ukuqinisekisa imininingwane, kanye / noma ukuthuthukisa ukuphuma kwewebhusayithi.


IJavaScript ivele okokuqala kwi-1995 אם כן kude kusukela lapho ngokwemigomo yokwamukelwa nokuthi isetshenziswa kanjani. תחביר I-esetshenziswe kuJavaScript yathonywa ngokuqinile yi-C; kodwa iJava, Pearl, Python, ne-Schema nayo nayo yadlala indima yayo.

Izeluleko Zokuqala zeJavaScript: Okudingayo Ukuze Ukwazi?

Okokuqala, izinto eziyisisekelo ezimbalwa okudingeka wazi:

  • אני-JavaScript ingavaliwe kusiphequluli
  • I-JavaScript izosebenza njalo lapho ikhasi lilayishwa
  • I-JavaScript ithatha isikhathi ukulayisha ngokuxhumeka kwe-Intanethi
  • I-JavaScript isasuka kumakhasi במטמון אלקטרוני
  • Ungabamba i-JavaScript ngaphakathi kwekhasi lewebhu noma ngaphandle kwefayela le-.js
  • I-JavaScript ihluke ngokuphelele kuneJava

Kubalulekile futhi ukuqonda ukuthi iJavaScript empeleni izokuholela enhlekeleleni uma isetshenziswa ngendlela engafanele.

Amakheli we-JavaScript akhiwe kahle futhi anobuhlakani azonciphisa iwebhusayithi yakho futhi alimaze ukuzulazula jikelele kwesayithi. Lokhu nakho kuthinta inani lokubuya kwezivakashi zakho (ngenxa yolwazi lomsebenzisi olubi) kanye namazinga ezinjini zokusesha (ngenxa yamanani wokuphendula wewebhusayithi aphambili kanye nokukhasa kwe-bot). Ukusiza ukuqinisekisa icala lami lapha, zifake ezicathulweni זוקובוקה. Uma iwebhusayithi oyivakashele ilayishe kancane, bekunzima ukuyisebenzisa, futhi, ukungavezi – ngabe ubuyela kusayithi? נג’קה.

Ngezansi kunohlu oluncane lwezinto okufanele ucabange ngazo lapho jongeza iJavaScript kuyo iwebhusayithi yakho.

  • אני משתמש ב- JavaScript אירינגה וקותי איזאתי איזבלזה קאלה?
  • Isayithi lizobonakala kanjani uma i-JavaScript ivinjelwe?
  • I-JavaScript izolimaza ukusebenza kweseva?
  • אינגבה uzongeza ukusiza כל JavaScript- ukuhambisa isayithi lakho ngendlela ofuna ukuyifaka ngayo?

צ’ה, אנגיזאמי ukukusabisa ngala maphuzu.

Eqinisweni, ungesabi Sebenzisa iJavaScript kuwebhusayithi yakho njengoba ihlinzeka ngezinzuzo zamathani futhi, njengoba kushiwo, isetshenziswa ezinkulu. Iphuzu eliyisihluthulelo engizama ukulifinyelela lapha akuyona nje ukuqhubeka unezela izici zeJavaScript kusayithi lapho kungenasidingo khona. Amanye amasayithi azodinga iJavaScript enkulu kunamanye; ezinye zidinga okuncane nje – אוקותי isayithi eyodwa iyayenza akusho ukuthi nawe kufanele wenze okufanayo.

I-Freebies: I-15 מגניב I-JavaScript Imiklamo Yewebhusayithi Yakho

Manje, ake sehle kulokho okufike lapha – ngezansi uhlu lwama-snippets e-15 JavaScript azothuthukisa isayithi lakho ngokusebenza noma ukubukeka. Ikhodi izophulwa ibe yizingxenye ezimbili, ikhanda nomzimba noma ifayela le- .js. אומה קונגאנייקזאווה איזילוקו ססיגאבה נג’וחו-קיי אסיידקי קולסו סלתי אסיתיל.

I-1. Ukuqonda ividiyo ye-HTML5

Isampula esheshayo

umsebenzi uyaqonda_video () {חזרה !! document.createElement (‘וידאו’). canPlayType; // boolean} uma (! ukuqonda_video ()) {// Kufanele kube yisipheqululisidala noma i-IE. // Mhlawumbe yenza ל- efana nokufihla izilawuli // HTML5 Izilawuli. Noma yini … videoControls.style.display = ‘אין’; }

קטע קוד i-JavaScript של Yenzani?

Le קטע מצפן izokuvimbela iwebhusayithi yakho ukuthi izame ukubonisa ividiyo isiphequluli esinakukwazi ukusekela, ukulondoloza amandla omgwaqo kanye nokucubungula amandla.

I-2. Amakhukhi weJavaScript

Isampula esheshayo

/ ** * Imisa ikhukhi ngegama elinikeziwe nenani. * * איגאמה איגמה לה-קוקי * אינאני לה-קוקי * [ליפללה ווהיסיקהאתי] איזיקאת’י סוקופלהלווה קוקוח’י (אוקוזנזאקאלאלאיו: איכואיזלה איליאיזה איליזה ((ezenzakalelayo: isizinda sedokhumenti yokushayela) * [evikelekile] Inani le-Boolean elibonisa uma ngabe ukuhanjiswa kukhukhi kudinga ukuhanjiswa okuphephile * / ukusebenza setCookie (igama, inani, uukphelwa isoku + "=" + ukuphunyuka (אינני) + ((kuphelelwa isikhathi)? "; kuphelelwa isikhathi =" + expires.toGMTString (): "") + ((אינדללה)? "; אינדללה =" + אינדללה: "") + ((איזיזינדה)? "; תחום =" + תחום: "") + ((kuvikelekile)? "; kuvikelekile": ""); } / ** * Ithola inani le-cookie echaziwe. * * איגאמה איגאמה לה-קוקי אוייפונאיו. * * Ibuyisa intambo equkethe inani lekhukhi echaziwe, * noma i-null uma ikhukhi lingekho. * / פונקציה GetCookie (igama) {var dc = document.cookie; קידומת var = igama + "="; var qala = dc.indexOf (";" + איזיקאלו); uma (qala == -1) {qala = dc.indexOf (isiqalo); אמה (קאלה! = 0) buyela null; } okunye {qala + = 2; } var end = document.cookie.indexOf (";", קאלה); אמה (ukuphela == -1) {end = dc.length; } קנו ubuwena (dc.substring (qala + prefix.length, end)); } / ** * Unamathisela ikhukhi elibekiwe. * * Igama legama le-cookie * [indlela] yendlela yekhukhi (kumele ifane nendlela esetshenziselwa ukudala ikhukhi) * [domain] תחום העוגיה (kumele ilingane nesizinda esisetshenziselwe ukudala ikhukhi) * / פונקציה DeleCookie india (igiz, (GetCookie (igama)) {document.cookie = igama + "=" + ((אינדללה)? "; נתיב =" + אינדללה: "") + ((דומיין)? "; איזיזינדה = "+ תחום:" ") +"; תפוג = יום חמישי, 01-ינואר -70 00: 00: 01 GMT "; }}

קטע קוד i-JavaScript של Yenzani?

Le snippet isikhashana kodwa iwusizo kakhulu, izovumela isayithi lakho ukuthi ligcine ulwazi kwikhompyutha yombukeli bese lifunda kwelinye iphuzu ngesikhathi. Le snippet ingasetshenziswa ngezindlela eziningi ezahlukene zokufeza imisebenzi ehlukile.

I-3. Layisha kuqala izithombe zakho

Isampula esheshayo

izithombe ze-var = i-Array entsha (); i-preloadImages () {אתם (i = 0; i

קטע קוד i-JavaScript של Yenzani?

Le snippet izovimbela isayithi lakho ukuthi lingabi nesikhathi esibucayi lapho ibonisa kuphela ingxenye yesayithi; Lokhu akukona nje kubukeka kubi kodwa futhi akusizi ngalutho. קונקה okumele ukwenze wengeze izithombe zakho esigabeni sokulayisha kuqala futhi ulungele ukugoqa.

I-4. Ukuqinisekiswa kwe-imeyili

Isampula esheshayo

Inhloko:

umsebenzi uqinisekisa דואר אלקטרוני (theForm) {if (/ ^ w + audiotaurwa-> /.test(theForm.email-id.value)) {לקנות (iqiniso); } isexwayiso ("Ikheli le-imeyili elingavumelekile! Sicela ufake futhi ngokucophelela !."); buyela (ngamanga); }

אומזימבה: Ikheli le-Imeyili:

קטע קוד i-JavaScript של Yenzani?

Le-snippet izokuqinisekisa ukuthi ikheli le-imeyili elifomethwe kahle lifakwe kwifomu, alinakuqinisekisa ukuthi ikheli le-imeyili langempela, akukho ndlela yokukuhlola lokho ngeJavaScript.

I-5. Akukho Qhafaza kwesokudla

Isampula esheshayo

umsebenzi f1 () {אומה (amaphepha.all) {buyela amanga; }} sebenza f2 (e) {if (document.layers || (document.getElementById &! document.all)) {if (e.which == 2 || e.which == 3) {buyela amanga; }}} uma (document.layers) {imibhalo.captureEvents (Umcimbi.MOUSEDOWN); idokhumenti.onmousedown = f1; } okunye {document.onmouseup = f2; umqulu.oncontextmenu = f1; } idokhumenti.oncontextmenu = omebenzi omusha ("buyisa אמנגה");

קטע קוד i-JavaScript של Yenzani?

Le snippet izovimbela umbukeli ukuba akwazi ukuchofoza ngakwesokudla ekhasini lakho. Lokhu kunganciphisa umsebenzisi ojwayelekile ukuboleka izithombe noma ikhodi kusuka kusayithi לאקו.

I-6. חומביסה איצקפונו ezingekho emthethweni

Isampula esheshayo

ראש: bhalaRandomQuote = umsebenzi () {var quotes = מערך entsha (); izingcaphuno [0] = "Isenzo yisilinganiso sangempela sobuhlakani."; izingcaphuno [1] = "אני-בייסבול inenzuzo enkulu phezu kwekhilikithi יוקוטי שוטף את האיפלה."; izingcaphuno [2] = "Yonke inhloso, Yonke Isenzo, Yonke Imicabango, nakho konke ukuzwa, noma ngabe kukaziwa noma kungaziwa, ngumzamo wokukhulisa izinga lokuthula kwengqondo."; izingcaphuno [3] = "Inhloko enhle nenhliziyo enhle zihlala ziyinhlanganisela ebabazekayo."; var rand = Math.floor (Math.random () * izingcaphuno.length); umqulu.write (izingcaphuno [zamarandi]); } bhalaRandomQuote ();

אומזימבה: bhalaRandomQuote ();

קטע קוד i-JavaScript של Yenzani?

Kulungile lokhu akusiyo ishidi ukuthi zonke izingosi zingasebenzisa kodwa zingasetshenziswa ukubonisa okungaphezulu nje kokucaphuna okungahleliwe. Ungashintsha okuqukethwe ok izingcaphuno kunoma yini oyifunayo futhi ube nezithombe ezingahleliwe noma umbhalo oboniswe noma kuphi kusayithi לאקו.

I-7. איזיקסומניסי זנגאפמביליני / אזילנדלו

Isampula esheshayo

Ikhasi langaphambilini | Ikhasi elilandelayo

קטע קוד i-JavaScript של Yenzani?

Le snippet inkulu uma unamakhasi amaningi ku-athikili noma kusifundo. Izovumela umsebenzisi ukuthi upheqa phakathi kwamakhasi kalula. Kuyinto encane futhi isisindo esincane esivela endaweni יוקובוקה.

I-8. Beka i-bookmark ekhasini

Isampula esheshayo

קטע קוד i-JavaScript של Yenzani?

Le snippet izovumela umsebenzisi ukuthi azimise ikhasi lakho kalula; konke okumele bakwenze ukuchofoza isixhumanisi. איזיצ’י זיו ezincane ezifana nalokhu ezingandisa ababukeli bakho ulwazi jikelele.

I-9. Isixhumanisi Esilula Sekhasi Lefepha

Isampula esheshayo

Ikhasi Lokuphrinta

קטע קוד i-JavaScript של Yenzani?

Lesi sixhumanisi esincane sizovumela imibono yakho ukuba iphrinta kalula ikhasi lakho. Isebenzisa isici sokuphrinta esheshayo sesivele sisethiwe ngesiphequluli sakho futhi asisebenzisi izinsiza kuze kuchofozwe.

I-10. Khombisa usuku oluhleliwe

Isampula esheshayo

ראש: show showDate () {var d = usuku olusha (); var curr_date = d.getDate (); var curr_month = d.getMonth () + 1; // izinyanga אפס אפס curr_year = d.getFullYear (); umqulu.write (curr_date + "-" + חודש_חודש + "-" + curr_year); }

אומזימבה: showDate ();

קטע קוד i-JavaScript של Yenzani?

Le snippet izokuvumela ukuba ubonise usuku lwamanje noma kuphi ekhasini lakho lewebhu futhi akudingeki libuyekezwe. Mane nje uyibeke endaweni futhi ukhohlwe ngakho.

I-11. Isihlukanisi seComma

Isampula esheshayo

ראש: i-function addCommas (inombolo) {num + = ”; var n1 = inombolo.split (‘.’); var n2 = n1 [0]; var n3 = n1.length> 1? ‘.’ + n1 [1]: ”; var temp = / (d +) (d {3}) /; ngenkathi (temp.test (n2)) {n2 = n2.replace (temp, ” + ‘,’ + ”); } var out = החזר n2 + n3; umqulu.bhala (ngaphandle); }

אומזימבה: i-addCommas ("4550989023");

קטע קוד i-JavaScript של Yenzani?

Le snippet ingasetshenziswa ikakhulukazi amasayithi asebenzisa izinombolo kaningi. Le snippet izogcina izinombolo zakho zibukeka ezifanayo ebhodini. קונקה okumele ukwenze ukukopisha umugqa womzimba lapho ufuna ukwengeza khona inombolo bese ushintsha inombolo lapho ngenombolo yakho.

I-12. תולה אינוואו יוקובוניסה יסיפקולולי

Isampula esheshayo

Ububanzi besikhathi Sakho sokubuka ngu ‘+ viewportwidth +’ x ‘+ viewportheight +’

‘); // ->

קטע קוד i-JavaScript של Yenzani?

Le snippet izokuvumela ukuthi uthole ububanzi nokuphakama kwendawo yokubonisa kusiphequluli sakho sokubukwa. Lokhu kuzonikeza umklami ikhono lokudala nokusebenzisa izibonisi ezahlukene ngokususelwa kusayizi wesiphequluli sesiphequluli לפעמיםebenzisi.

I-13. Phinda uqondise kabusha ngokubambezeleka kokukhetha

Isampula esheshayo

setTimeout ("windows.location.href = ‘http://walkerwines.com.au/’", 5 * 1000);

קטע קוד i-JavaScript של Yenzani?

Le snippet izokuvumela ukuba uqondise kabusha ababukeli bakho kwenye ikhasi futhi unendlela yokubeka ukulibaziseka. קטע Ukusetshenziswa kwalesi kuyinto משפר ozichaza futhi kuyithuluzi eliwusizo kakhulu ukuba תינוק ebhande לאקו.

I-14. Thola ama-iPhones

מדגם

uma ((navigator.userAgent.match (/ iPhone / i)) || (navigator.userAgent.match (/ iPod / i)) {if (document.cookie.indexOf ( "iphone_redirect = אמנגה") == -1) {windows.location = "http://m.espn.go.com/wireless/?iphone&i = COMR"; }}

קטע קוד i-JavaScript של Yenzani?

אני מביא את ה- izokuvumela בבריטניה לנקוב בבחינת השימוש באייפון עם ה- iphone ו- iPod כדי להגן על הקוביה והקובו. Lo mdlalo uzuzisa kakhulu kangakanani ukuthi imakethe yeselula ikhulu kangakanani futhi uzoqhubeka ukhula.

I-15. פרינה אמיליזו קו-איסימו בר

Isampula esheshayo

“; // ->

קטע קוד i-JavaScript של Yenzani?

Le קטע מצפן izokuvumela ukuthi uphrinte umlayezo kubha yomumo. Ungabonisa izindaba zakamuva noma ezibalulekile endaweni ezobamba iso lomsebenzisi.

Jeffrey Wilson Administrator
Sorry! The Author has not filled his profile.
follow me