Slashdot Mirror


Web 2.0 Recipes With PHP + DHTML

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."

37 of 134 comments (clear)

  1. Hmmm.... by Anonymous Coward · · Score: 3, Interesting

    This will make for some interesting comments. Begrizzled hippies whining about Javascript. Puzzled newbies arguing the merits of PHP. Flamefests over ruby on rails and other frameworks. Etc.

    1. Re:Hmmm.... by Intron · · Score: 4, Funny

      Us begrizzled hippies used the tag for this stuff.

      --
      Intron: the portion of DNA which expresses nothing useful.
    2. Re:Hmmm.... by mattwarden · · Score: 2, Insightful

      Sure, if you want to keep promoting non-standard garbage. Please try to use the cross-browser, standards-compliant, Web 2.0 version of the blink tag in the future.

  2. BAM! by Metabolife · · Score: 4, Funny

    "including: Ad boxes, Pop-ups, Spinners, and Tabs. Easy ways to show and hide content on the page." Then you just mix it in the bowl and BAM! You have upset customers and lost respect!

  3. Shock by shoma-san · · Score: 2, Funny

    Wow, he's using Apple to view/code his site. He might already be riddled with a ton of viruses (I read the McAfee Feigns Fear at Mac Security article). Better not try this at home without McAfee!

  4. IE Script Warnings by serutan · · Score: 4, Insightful

    My biggest hesitancy in using javascript is the IE warning bar that makes any page containing script look threatening. It's no problem with Foxfire, but most people still use IE. How many of them would see that warning and just assume something bad is lurking if they click Allow?

    1. Re:IE Script Warnings by Tx · · Score: 4, Funny

      For a minute there I thought you meant the bar at the top that says "Microsoft Internet Explorer", makes every website look threatening to me ;)

      --
      Oh no... it's the future.
    2. Re:IE Script Warnings by eggz128 · · Score: 4, Informative

      My biggest hesitancy in using javascript is the IE warning bar that makes any page containing script look threatening


      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.
  5. Wow by aftk2 · · Score: 5, Informative

    This article's been on the front page for a couple of minutes, with no comments. Perhaps Web 2.0 is tired?

    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, 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.

    --
    concrete5: a cms made for marketing, but strong enough for geeks.
    1. Re:Wow by ultranova · · Score: 5, Informative

      Now, on a website I built, 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.

      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.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    2. Re:Wow by RomulusNR · · Score: 2, Informative

      No, the problem is that Web 2.0 does not equal DHTML, or even AJAX, which is really just DHTML with back-room data loading. The article admits shamelessly it's just about DHTML. The difference between DHTML and Ajax is the difference between Experts Exchange and Google Mail.

      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?

      --
      Terrorists can attack freedom, but only Congress can destroy it.
    3. Re:Wow by ticklemeozmo · · Score: 2, Insightful

      This article's been on the front page for a couple of minutes, with no comments. Perhaps Web 2.0 is tired?

      I don't think it's that. It's just.. rehashed drek from other websites with a .ibm.com domain name.

      Really, there is NOTHING new in that tutorial that hasn't been done on other beginner websites. Nothing here is really Web 2.0, it's just hiding divs. That was in Javascript a long time ago. There's no backend business, no combining with other technologies. No data being "fetched", no integration with a db, no real css stylings. Just.. "visible" or "hidden".

      --
      When modding "Informative", please make sure it both has a source and IS actually informative.
    4. Re:Wow by heinousjay · · Score: 2

      He could also just have the user mail the comment in using the postal system, but that is also not slick.

      --
      Slashdot - where whining about luck is the new way to make the world you want.
    5. Re:Wow by Tim+Browse · · Score: 3, Funny
      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?

      Defining Web 2.0?

      Well, that is a fun game, to be sure, but I prefer Mornington Crescent. The rules are less nebulous.

  6. The worst page ever. by caluml · · Score: 4, Funny

    I wonder - we should have a competition to see who can make the most obnoxious web 2.0 page. Sort of like 1997 web "1" style - "under construction" gifs, flashing text, and scrolling status bars.

    1. Re:The worst page ever. by drspliff · · Score: 2, Funny

      Oh my friend, this is already being done, as featured in an article on TheDailyWtf.. HyperLink 2.0:

      # a translucent layer (DIV) is placed over the entire page, causing it to appear "grayed out", and ...
      # a "please wait" layer is placed on top of that, with an animated pendulum swinging back and forth, then ...
      # the XmlHttpRequest object is used to call the "GetHyperlink" web service which, in turn ...
      # opens a connection to the database server to ...
      # log the request in the RequestedHyperlinks table and ...
      # retrieves the URL from the Hyperlinks table, then ...
      # returns it to the client script, which then ...
      # sets the window.location property to the URL retrieved, which causes ...
      # the user to be redirected to the appropriate page

      No doubt Microsoft will catch onto this, very smart and complex ways of doing very dumb things :)

  7. Search Engine Visibility by fragmentate · · Score: 4, Insightful
    If you use JavaScript to render content, you're going to have a really hard time getting indexed by the search engines. If you're an individual, not such a big deal. If you're a company... make sure you have an alternative to pure javascript so that the search engine robots can find the content.

    Same goes for Flash...

    I can't believe how many companies spent tens of thousands of dollars on a CMS package, or to a "web designer" that rendered them invisible to the search engines.

    The article does recommend a fallback for unsupported browsers. Take this to heart, because "GoogleBot" is an unsupported browser.

    1. Re:Search Engine Visibility by oliderid · · Score: 2, Insightful

      Concerning FLASH a potential explanation is this real life experience.

      The CMS was installed and running for weeks but our client was still requesting modifications after modifications on the lay-out. HTML+CSS and nice visual. Nothing really wrong with it. Until that contract, Our lay-outs would only suffer few modifications before being accepted.

      Their profile: a medium interior design company.

      We were about to lose money. We spent more money on the lay-out than on the tool in itself. What's puzzled me is that Visuals were more important than the content for them. They couldn't care less about the newsletter module or the stat modules or the e-commerce module we have installed for their product. They didn't care that the space dedicated for the text (the content) was around of a paragraph's size. they wanted a beautiful web site. It should be beautiful, not efficient nor informative nor easy to update and google was a "detail" for them (the biggest source of new visits is a "detail")

      So...We end up with a bet: Use FLASH, make a lot of fanzy animations, and see what happens.

      Our clients were looking like kids to the "standard" animations you can get with the SWISH Max (89 Euro) software. That's probably the best investment I have ever done. 89 Euro have saved a 15K+ contract. They were extremely impressed, they tought that we have all spent a lot of extra hours to please them. In fact It took me with our poor web designer a couple of hours (To select some predined animations). We have also used another product called SWISHPIC to make FLASH pictures galeries...And that's it.

      Within a week the Lay-out/web site was accepted.

      We told them that witht his new technologies, they will have to pay us to update their picture galeries (no problem), that they would have to type twice the text to make newsletter (no problem), the homepage will be static and the menu too (strange for a CMS, isn't it) again no problem.

      They live in another world.
      FLASH has been made for customers like them.

  8. Web 2.0 by nstlgc · · Score: 3, Funny

    Stop calling it Web 2.0, you are making a total fool out of yourself. I thought meaningless buzzwords were for managers?

    --
    I'm Rocco. I'm the +5 Funny man.
  9. How useful is this? by Eideewt · · Score: 4, Insightful

    Except for the tabs, these all seem like a pretty bad idea. Nobody wants to click all over to get at information that could have just been displayed in the first place.

  10. Oh greaaaat... by radiotyler · · Score: 4, Insightful
    "...including: Ad boxes, Pop-ups, Spinners, and Tabs. Easy ways to show and hide content on the page."/i>
    Did we really need php/dhtml ad boxes and pop-ups? What, the good-ol' fashioned ones weren't annoying enough, or was there a strong demand for pretty dynamic pop-ups? This is one of those things that you see, and read the article and think, "Oh boy, I can't want to see this get implemented poorly and exploited." Anyone care to take any bets on how long it takes before this annoying crap is assulting us in ad format on a wide scale - or is it already?
    --
    hi mom!
    1. Re:Oh greaaaat... by kuzb · · Score: 3, Insightful

      Never worked in internet advertising before?

      Trust me, there is a strong demand for this stuff (it is in use already), and advertisers don't care how much it annoys you. In fact, it's been shown in our in-house studies that really annoying ads work better than ones that are not. This means, the more movement it has, and the more noise it makes, the more effective the ad will probably be. The solution? Convince everyone not to click on them. That would make them go away faster than anything.

      The fact of the matter really is that people click on this stuff. More than you probably realize.

      --
      BeauHD. Worst editor since kdawson.
    2. Re:Oh greaaaat... by radiotyler · · Score: 2, Interesting

      The double underlines thing drives me freakin' wild, man. The thing that bothers me about that is I think it's (un?)intentionally teaching people that the link that has been inserted into the article you're reading may not be endorsed by the site writing the piece, and getting people a bit paranoid about what they click on.

      Of course, this can all be cured by taking your information from "reputable" websites - but sometimes I like to visit the other side of the tracks, and it just makes me that much more cautious. Embedded ads and content just seem like a really bad idea to me. But what the hell do I know.

      --
      hi mom!
  11. Urge to kill...rising... by crerwin · · Score: 5, Funny

    Great, instructions for ad-boxes, pop-ups, and spinners (I stopped reading the article before I got to what spinners were, but I'm sure they're obnoxious). This is almost as bad as the fact that Macromedia has a forum on their site dedicated to creating ads. Some people just give humans a bad name.

    Next week: Your first phishing page with php and dhtml in just minutes!

  12. this is sad... by Jehlon · · Score: 4, Insightful

    I was hoping for some good code, it is from IBM after all, but its nothing more than crappy javascript from '99. Someone buy this guy the DOM Scripting book (http://www.domscripting.com/) and teach him what the seperation of structure (XHTML), presentation (CSS) and behavior (javascript) is all about.

  13. Why is this an article specifically? by Ahnteis · · Score: 2, Informative

    I ask because there are whole sites ( http://www.dynamicdrive.com/ ) that provide many more examples along with compatibility information. There are also huge sites with tutorials about developing your own scripts.

    So why choose this seemingly random PAGE that offers (as far as I can tell) nothing new?

  14. Stupid code by Bogtha · · 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:

    • The code doesn't use a doctype line. Not only does that preclude basic QA in the form of validation, but it kicks browsers into "quirks mode", which screws up CSS rendering.
    • The code uses href="javascript:...". This is stupid and wrong.
    • He just dumps content out wherever he likes, hides it with CSS and then shows it with JavaScript. So much for backwards compatibility. When CSS is not available, you'll just get random bits of content scattered throughout the page.

    That's just the tip of the iceberg. This is an exceptionally poor article.

    --
    Bogtha Bogtha Bogtha
  15. customer: overloaded variable. ambiguous. by NotQuiteReal · · Score: 4, Insightful

    Customers who use websites might not like that stuff, but customers who buy websites often love it and ask for it by name, and pay by the hour!

    --
    This issue is a bit more complicated than you think.
  16. What the... by Null+Nihils · · Score: 3, Insightful

    *cough* *sputter*

    ... I'm sorry... this isn't Web 2.0, this is Web 1996... this is... this is... I couldn't even cope with TFA, it was giving me horrible flashbacks from back when I wrote IE-only webpages because I didn't know any better.

    Seriously, I'm not trying to troll, I'm genuinely at a loss for words here... how... what...??? ...who are you people, and what have you done with Slashdot?

  17. Re:Cross-browser Flash. by Anonymous Coward · · Score: 4, Insightful

    Flash!

    Ah-aaaargh!

    Seriously though. Flash is an awful choice. One the plus side, you get fairly consistent rendering. On the minus side it completely fucks up your entire interface. Middle-click to open in a new tab? Right-click to bookmark? Shift-click to open in a new window? Ctrl-F? Find-as-you-type?

    Flash is great if you want to trade in the quality of the end result for ease of development. But I'd rather put a bit of effort in and get a decent interface rather than put little effort in and get crud. Crud that might look pretty, granted, but still a horrible, horrible interface.

  18. Who the fuck wrote this?! by Anonymous Coward · · Score: 5, Insightful

    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.

    Aaaaaaaaaaaaaahhh. My eyes are bleeding. What the fuck are you talking about?

    In the early days of HTML, Internet Explorer did not exist.

    Only IE and Netscape render pages differently?!

    Most of the CSS issues have been solved?!? What?!

    Javascript compatibility problems are new?@#$?@#$!?

  19. Gimmicks vs. Usefullness by ChrisMitchell · · Score: 2, Insightful

    From a practical point of view the information provided by the site in question is useless (not to take away from the efforts of those involved). The focus really should be on the convenient, useful aggregation of content, while providing ease of use for visitors to the site.

    I was roped in by the "wowee zowee" stuff as IE battled Netscape in the 90's. Eventually we all realized that coding to the lowest common denominator was the key to creating a consistent, error free experience for our end users.

    The bottom line is to make our sites useful. If done properly the sites can look great, be secure, provide great functionality and be compatible with all platforms. The caveat is that we remain at the mercy of browser quirks, making standards compliance a serious inconvenience for both users and developers.

    This is the direction that emerging (AJAX, for example, is not new. It IS emerging) techniques and technologies should be focused on. Such a focus could cause new tricks to enhance compatibility/usefulness across platforms.

    Thanks for letting me participate in the discussion!

    --
    WTF? I ordered a CHEESEburger!
  20. CSS Issues Have Not Been Solved by Mikey-San · · Score: 3, Insightful

    "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."

    CSS compatibility issues have been worked around; they have not been "solved", and any quick trip through Position is Everything or A List Apart will show you that. JavaScript compatibility issues have also been around since the first days of JavaScript implementation in browsers.

    Neither are going to "be solved", especially if Microsoft have anything to say about it. Right now, as in the past, implementation differences equal a certain degree of lock-in. The truth is that no rendering engine provides a complete, perfect-for-intents-and-purposes CSS2 implementation, and IE is easily at the bottom of that pack. Combined with its field dominance, it is largely responsible for "CSS compatibility issues".

    IE 7 isn't going to provide a better rendering engine than Gecko, KHTML/WebCore, or whatever Opera's engine is called; it will simply address a list of the most important problems, such as the infamous box model fuck-ups. There will not be a "kickass" rendering engine in IE 7, and as much as I hate to say it, that's going to keep us in compatibility hack hell for the near future.

    Now, if you ask me--and obviously you did, right, lol internet_rant--Microsoft have had more than ample time, people, and resources to produce a rendering engine on-par with Gecko and its peers. But that's not going to be the case. Only one reason for that.

    CSS compatibility issues mostly solved? Not even close.

    --
    Mikey-San
    Karma: +Eleventy billion (mostly affected by watching Celebrity Jeopardy)
  21. Crap Code Alert by porneL · · Score: 2, Interesting

    This code is crap. Use of <a href="javascript:"> makes it same quality as <marquee><font color="#ggggg">OMG Web 2.0!</td></font>

    Unlike TFA, here are some resources worth reading:

  22. Why I left front-end web development by onlyjoking · · Score: 3, Interesting

    I spent years wading through the quagmire of DHTML/CSS/Javascript compatibility issues and eventually realised that it was a full time job getting it right. 'Trouble was the job went largely unrewarded as the end user was only interested in how pretty it looked and it's difficult to get a client to pay you properly for time spent working round compatibility problems. Eventually I got wise and realised M$ had screwed up the CSS and Javascript game beyond recovery and decided to concentrate my energies where my time would be rewarded. I've been working with Perl, PHP, MySQL and PostgreSQL ever since and haven't looked back. For front-end design I keep it simple - basic CSS and no Javascript. That way I can sleep at night and wake refreshed to concentrate on the aspects of web development which add real value to a site. "Web 2.0" won't tempt me back into the fray as IE5/6 issues will haunt web developers for many years yet, regardless of what Vista and IE7 brings.

    One area of web development I think is very much neglected is semi-dynamic web development with Template Toolkit and cron. The content of many dynamic sites only changes periodically so it can often be better to have templates generate static pages periodically from your database with a cron script instead of coding the whole site in PHP, Perl/CGI or whatever.

  23. Re:Javascript by heinousjay · · Score: 2, Funny

    No one ever went broke ignoring 1% of the target market.

    --
    Slashdot - where whining about luck is the new way to make the world you want.
  24. This is new?? by oaksong · · Score: 2, Funny

    I was doing some of this dhtml and java scripting 6 years ago. Where have these people been? (Oh! It's IBM. never mind)