13.02.2013 Views

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

{<br />

modules1Modules[modules1Modules.length] = divs[i].getAttribute("id");<br />

}<br />

}<br />

document.cookie = "modules1=" + modules1Modules.join(",");<br />

var modules2 = document.getElementById("modules2");<br />

var modules2Modules = [];<br />

var divs = modules2.getElementsByTagName("div");<br />

for (var i = 0; i < divs.length; i++)<br />

{<br />

if (hasClass(divs[i], "module"))<br />

{<br />

modules2Modules[modules2Modules.length] = divs[i].getAttribute("id");<br />

}<br />

}<br />

document.cookie = "modules2=" + modules2Modules.join(",");<br />

}<br />

return true;<br />

};<br />

Now when a module is repositioned, two cookies are written. For each module area, the divs with a class of module are<br />

found and their IDs added to an array. The array will reflect the order of the modules, as getElementsByTagName() returns<br />

elements in source order. Once the array has been completed, it is written into a cookie—either modules1 or modules2,<br />

depending on the circumstances, with each of the IDs separated by a comma.<br />

When these cookies are passed to the server, you should be able to use them to check the order of the modules and write<br />

them into the web page in the appropriate order.<br />

Conclusion<br />

The diversity of user needs—whether technological or task-based—is challenging the traditionally static form of the Web.<br />

Creating dynamic interfaces is one of the ways that you can help to meet those needs. The two techniques I’ve described<br />

here demonstrate how the flexibility of standards-based web pages can change the way in which we design for the Web.<br />

chapter 9 Creating Dynamic Interfaces Using JavaScript<br />

241

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!