Web Programming with html5, css, and JavaScript



Download 18,68 Mb.
Pdf ko'rish
bet75/98
Sana28.10.2022
Hajmi18,68 Mb.
#857632
1   ...   71   72   73   74   75   76   77   78   ...   98
Bog'liq
Web Programming with HTML5, CSS, and JavaScript

488
ChaptER 10
 
Loops, Additional Controls, Manipulating CSS with JavaScript


In Figure 10.24A, note the ten pairs of statements that have this form:
li = getli(...);
ul.appendChild(li);
The 
getli
function call retrieves a new 
li
element from the subordinate 
getli
function 
you’ll see shortly. But before getting into that, let’s continue with the code in Figure 10.24A. 
Each of these pairs of statements creates one button and adds it to the unordered list of but-
tons that will go at the top of the current web page. After the list of buttons is complete, an 
appendChild(ul)
call inserts it into the empty 
nav
element. Then an 
appendChild(nav)
call adds the 
nav
element to the 
header
element—after the previously inserted 
h1
title. The 
final statement in Figure 10.24A inserts the fully populated 
header
element into the 
body
FIGURE 10.24a 
JavaScript that adds a heading and adds header and footer navigation 
buttons to web page being loaded
function createHeaderFooter() {
var h1 = document.createElement("h1");
var header = document.createElement("header");
var footer = document.createElement("footer");
var nav = document.createElement("nav");
var ul = document.createElement("ul");
var li;
h1.innerHTML = "Microgrid Development in Lawrence KS";
header.appendChild(h1);
li = getli("electricPowerHistory.html", "Electric Power History");
ul.appendChild(li);
li = getli("lawrenceHydropower.html", "Lawrence Hydropower");
ul.appendChild(li);
li = getli("index.html", "Area Description");
ul.appendChild(li);
li = getli("microgridPossibilities.html", "Microgrid Possibilities");
ul.appendChild(li);
li = getli("typicalProperty.html", "Typical Property");
ul.appendChild(li);
li = getli("localEnergy.html", "Local Energy");
ul.appendChild(li);
li = getli("collectorPerformance.html", "Collector Performance");
ul.appendChild(li);
li = getli("services.html", "Electric Power Services");
ul.appendChild(li);
li = getli("#", "Downtown Properties");
ul.appendChild(li);
li = getli("#", "Solar Shadowing");
ul.appendChild(li);
nav.appendChild(ul);
header.appendChild(nav);
document.body.insertBefore(header, document.body.childNodes[0]);
489
10.17 Case Study: Collector Performance Details and Nonredundant Website Navigation


element—before any other material already in the body of the current page. (That other mate-
rial is all the elements in the 
body
of the html code that called this 
createHeaderFooter
JavaScript function.)
Before moving on, notice the 
"#"
values in the first arguments of the final two 
getli
func-
tion calls. These are the dummy addresses of web pages that have not yet been created. This 
navigation.js
file is the 
only
place one needs to go to register a newly created web page! This 
simple update to the common 
navigation.js
file is the only existing-code change needed 
when a new web page is added.

Download 18,68 Mb.

Do'stlaringiz bilan baham:
1   ...   71   72   73   74   75   76   77   78   ...   98




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish