Web 2.0 Recipes With PHP + DHTML 134
An anonymous reader writes "Take a look at these full simple code examples for dynamic elements for your web apps, including: Ad boxes, Pop-ups, Spinners, and Tabs. Easy ways to show and hide content on the page." From the article: "Incorporating JavaScript into your page makes the page dynamic and creates a more compelling user experience. Users can get more data more quickly, look at information from different aspects, and seamlessly navigate the site -- and the site doesn't have to go back to the server for lots of pages. However, there's also a reason to avoid using JavaScript: browser compatibility. In the early days of flat HTML, Internet Explorer rendered pages differently from Netscape. Those problems were fixed, but when support for CSS was added, new compatibility issues arose. Now most of the CSS issues have been solved, but JavaScript compatibility issues have cropped up. These compatibility problems have no easy solution. You need to weigh the benefit of what the JavaScript is doing against the number of browsers you'll need to test against and support."
Wow (Score:5, Informative)
For me, I really like JavaScript and AJAX when it helps to actually improve the user experience. Dynamic tabs? What's the point? How is it really functionally than just heading to a different page, or using some middleware to control what content is served, after a page reload?
Now, on a website I built [theportlandscene.com], I've used AJAX (shudder) to create a commenting system that doesn't require the user to initially be logged in. The user can visit a page, submit a comment through the form, and if the user isn't logged in, they're presented with the ability to login right then and there, without losing their comment, and without even being shuttled off to a different section of the site, wondering if their comment will post when they're finished. If they don't have an account, they can create one right there. I think those kinds of tricks make remote scripting worthwhile.
Plus, I think adding new widgets to HTML through JavaScript is pretty keen - like the sliders and calendar that Yahoo is making available under the BSD license at their developer area [yahoo.com].
Re:IE Script Warnings (Score:5, Informative)
That only happens on XP post SP2 and when the content you are viewing is on a local drive. Once your page is uploaded -- or if you give it "The mark of the web" (Google for it) on your local drive -- the yellow warning bar no longer appears.
Re:Wow (Score:5, Informative)
Or you could just have the comment submit form include "username" and "password" fields if the user is not logged in, and if you need to go to another page to create an account, move the comment text around in a hidden field. No reason whatsoever to use user-side scripting, just good old PHP / JSP / ASP / whatever.
Why is this an article specifically? (Score:3, Informative)
So why choose this seemingly random PAGE that offers (as far as I can tell) nothing new?
Re:Wow (Score:3, Informative)
I guess "Web 2.0" will never be defined. Is Web 2.0 "thick client" browsing, or is it providing and soliciting community-enhanced content?
Stupid code (Score:5, Informative)
IBM's JavaScript articles are usually high quality. But this one is awful. It uses invalid code, it doesn't degrade gracefully, it mixes HTML, CSS and JavaScript into the same file instead of separating them, and it breaks when you try and do things as simple as open a link in a new tab.
Don't be fooled by the "senior software engineer with more than 20 years of experience" author, this guy doesn't know the most basic, newbie things. I can only imagine that his 20 years of experience was with something other than HTML, CSS and JavaScript. For example:
That's just the tip of the iceberg. This is an exceptionally poor article.
Re:Stupid code (Score:1, Informative)
SWT calls what he was doing an ExpandBox and I've also seen them called Accordions.
Re:Wow (Score:2, Informative)
No, PHP is tired. It's now all about Ruby [ruby-lang.org], Python [python.org], LISP [gigamonkeys.com], and the more obscure but no less interesting Lua [lua.org], Scala [scala.epfl.ch], Qi [lambdassociates.org], OCaml [extremetech.com], among others, and various [rubyonrails.org] derivatives [djangoproject.com] and frameworks [turbogears.org].