Yuav Ua Li Cas Rau Embed Tsab Ntawv Hauv Html

Cov txheej txheem:

Yuav Ua Li Cas Rau Embed Tsab Ntawv Hauv Html
Yuav Ua Li Cas Rau Embed Tsab Ntawv Hauv Html
Anonim

HTML yog hom lus markup rau cov nplooj ntawv web uas muaj lub luag haujlwm rau ua kom pom cov duab graphical thiab cov ntawv nyeem. Nws kuj tseem siv tau los siv cov ntawv sau sau ntau yam lus programming. Lub ntsiab tshwj xeeb yog siv los ntxig tsab ntawv rau HTML.

Yuav ua li cas rau embed tsab ntawv hauv html
Yuav ua li cas rau embed tsab ntawv hauv html

Cov Lus Qhia

Kauj ruam 1

Txoj cai tuaj yeem tso rau ntawm nplooj ntawv ob qho tib si hauv lub cev ntawm cov ntaub ntawv thiab hauv ntu. Koj tuaj yeem siv tus xov tooj tsis muaj qhov txwv kom ntxiv cov ntsiab lus nquag. Qhov loj tshaj plaws yog tias cov ntawv sau ntxiv tsis cuam tshuam nrog cov zaub ntawm cov ncauj lus tseem ceeb. Yuav kom hloov cov HTML code, qhib koj nplooj ntawv hauv txhua cov ntawv nyeem kho. Webmasters feem ntau siv cov kev zov me nyuam uas tau piav qhia cov lus piav qhia hauv lawv txoj haujlwm: Notepad ++, Web Development Studio, HTML Reader. Cov ntawv thov tseem tuaj yeem tuaj yeem qhib qhib siv daim ntawv thov Notepad ntawm lub Windows ua haujlwm.

Kauj ruam 2

Hauv kab ntawv nyeem lub qhov rai, ntaus cov HTML code. Piv txwv li, txhawm rau txhawm rau JavaScript hauv nplooj ntawv, siv cov lus txib nram qab no:

Code rau txim tuag

Cov kev cai uas sau tseg yuav raug tua rau ntawm nplooj ntawv tso tawm thiab yuav tua nyob rau ntawm phau ntawv piav qhia. Hauv qhov xwm txheej no, hom parameter qhia rau tus tswj xyuas paub tias JavaScript hom lus yuav siv tom ntej.

Kauj ruam 3

Txhawm rau kom tsab ntawv los ua cov txheej xwm tshwj xeeb, piv txwv li, thaum lub pob nyem, nws yuav tsum muab tso rau hauv ib txoj haujlwm. Hauv seem, sau lub cim code:

Muaj nuj nqi displayDate ()

{daim ntawv.getElementById ("ua"). innerHTML = Hnub (); }

Tus lej JavaScript no yog lub luag haujlwm los nthuav tawm lub sijhawm tam sim no ntawm nplooj ntawv, tab sis kom pom nws ntawm tus saib, koj yuav tsum sau ib lo lus txib ntxiv txhawm rau los ua cov ntawv luam tawm thaum lub sijhawm ua haujlwm.

Kauj ruam 4

Hauv lub cev ntawm daim ntawv siv HTML, tsim lub pob uas yuav ua lub luag haujlwm rau kev ua kom lub caij:

Qhia sijhawm

Cov cai no tsim lub pob lus JavaScript tuav. Tom qab txhaj nws, qhov tshwm sim ntawm tsab ntawv yuav tshwm.

Kauj ruam 5

Txhawm rau hauv HTML ib qho kev sau ntawv sab nrauv nyob hauv ib daim ntawv tshwj xeeb, koj yuav tsum khiav txoj cai hauv qab no:

Ib zaug ua tiav, cov ntawv sau tshwj xeeb uas muaj npe file.js yuav suav nrog hauv nplooj. Nws yog tsim nyog sau cia tias cov ntaub ntawv sab nraud yuav tsum tsis muaj cov ntsiab lus rau qhov ua tiav zoo ntxiv.

Pom zoo: