Ixabiso leenombolo kunye noGcino lwasekhaya ngeHTML5

NguAndy Harris

Nge-HTML5, ungabhala ufike kwi-5MB yedatha kwindawo ekhethekileyoUgcino lwasekhayaifayile kwikhompyuter yomthengi. Onke amaphepha avela kwi-domain yakho abelana ngendawo efanayo yokugcina, ukuze usebenzise le ndlela ukugcina idatha iqhubeka phakathi kwamaphepha amaninzi. Idatha ihlala kumatshini wabathengi (de uyisuse), inokusetyenziselwa ukugcina umkhondo wolwazi ngokuhamba kwexesha.



Ukuba usebenza nedatha yamanani, khumbula okoUgcino lwasekhayaigcina yonke into njengomtya. Ayongxaki ukugcina ixabiso lamanani kwiUgcino lwasekhaya, kodwa xa uyibuyisa, kuyakufuneka uguqule ixabiso libuyele kwixabiso lamanani (ngeI-parseInt ()okanyeparseFloat ()kuhlobo lwedatha oyifunayo. Nanku umzekelo obala inani lamaxesha umsebenzisi ahambele indawo yakho:



 function countVisits(){ str_count = localStorage.getItem('count'); //get a numeric value from str_count, put it in count if (str_count == null || str_count == 'null'){ count = 0; } else { count = parseInt(str_count); } // end if //increment count count++; //display count lblCounter = document.getElementById('lblCounter'); lblCounter.innerHTML = 'You have been here ' + count + ' times'; //store count localStorage.setItem('count', count); } // end count

Le khowudi iya kufuna ukuqhutywa ngalo lonke ixesha iphepha lilayishiwe (mhlawumbi ngeuphawu).

  1. Zama ukufumana ukubala ukusuka indawo yokugcina .



    Sebenzisa iumtya_isimaphambili sokukukhumbuza ukuba idatha okwangoku ngumtya.

  2. Qinisekisa ukuba ixabiso likhona.

    Ukuba akukho kungena kwiziko ledatha le-bala, oku kuya kuba sisihlandlo sokuqala umsebenzisi elapha (okanye bacoca isiseko sedatha). Kuzo zombini iimeko, nikezela ixabiso0ukuyabala(olwahlukileyo lwamanani).



  3. Ukubastr_ibaloikhona, yiguqulele kwinani elipheleleyo.

    Sebenzisa iI-parseInt ()indlela yokuguqula umtyastr_ibalokwinani elipheleleyobala.

  4. Yongeza enye kwibala.

    Ngoku ubalalinani elipheleleyo, ungongeza kulo.

  5. Bonisa ixabiso lokubala kumsebenzisi.

    Ewe oku akuyomfuneko kwaphela, kodwa kulungile ukunika ingxelo ethile.

    imifanekiso yamashumi eperokhethi
  6. Ivenkilebala buyela kwi Ugcino lwasekhayaiziko ledatha.

    Qaphela ukuba ungagcina inani elipheleleyobalakwiziko ledatha ngaphandle kwengxaki. Iya kuguqulwa buthule ibe ngumtya xa igcinwe.