|
Multicolumn Layouts and Web Grids. 9. Client side dynamic approach. There is one last subject to cover before moving on to more complex layouts. This is the use of client side scripting. Usually the preferred language is JavaScript. The uses of client side scripting are many, but when regarding to web grids, the most udeful application of client side scripting is dynamic formatting of the page dependind on the user's browser or resolution. Many web developers like absolute positioning for their websites but are constantly troubled with the issue that even if they have great care, webpages are usually rendered differently from one browser to another, not to mention that along different resolutions the change can be quite amazing. It is at this time that client side scripting comes to help. By this method the webpage can get to know the user's browser and resolution and adapt consequently. You may have already noticed that this site uses these techniques, it uses PHP for dynamic content management, it uses a layer based layout and it uses client side scripting for adapting to the user resources (among other things). The result, altogether can be quite impressive, specially from the technical side, since it cuts down the maintenance of the site while offering a broad range of options for all kind of visitors. Although some knowledge on JavaScript is needed to further use this technique, I want to give you some code to help you out on dynamically sizing your pages, with this code snippet you can get the window's measures and store them in a variable, what you do with that is up to your imagination. var wnWidth = 0, wnHeight = 0; function heightGrabber(){ if( typeof( window.innerWidth ) == 'number' ) { //Non-IE } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible } } This code is totally cross-browser compatible and can be complemented by some other fucntions, but I'll leave that to you. Next, what you were already expecting for so long. Read on, complex layouts are coming. |
Affiliates | |