Posts

Showing posts with the label javascript

Introduction to Unobtrusive Javascript

Unobtrusive JavaScript  is an approach to the use of JavaScript in web pages to achieve its basic principles as below: • Separation of functionality (the “behavior layer”) from a Web page’s structure/content and presentation. • Best practices to avoid the problems of traditional JavaScript programming (such as browser inconsistencies and lack of scalability) • Progressive enhancement to support user agents that may not support advanced JavaScript functionality. Separation of behavior from markup Traditionally Javascript is fed into inline HTML document markup as a functions or query. Lets consider typical implementation of JS form validation when placed inline: <input type=" text " name=" date " onchange=" validateDate() " /> Adherents of “Unobtrusive JavaScript” contend that purpose of markup is to describe a documents structure, not its programmatic behavior .Also the inline event handlers are harder to use and maintain, when one needs to set handl