Optimalworks Ltd web design, SEO, training and consultancy 

the site completely surpassed my expectations GT, AutoDirector, we build websites that work, my website is great - I love it MP, XL Autos, reach more customers, make more sales, it's more than I ever could have expected LM, Trade Cars UK, we can help your business grow, 99% of business now comes from my website GV, Bash Events, promoting standards throughout the web industry, your contribution added a level of quality we would otherwise have struggled to achieve PS, Hemsley Fraser
  1. home
  2. Services
  3. Portfolio
  4. Contact us
  5. blog

JavaScript in-place document updates

written by Craig, 12 July 2007

One of our most popular web products is AutoDirector. It’s a PHP application that allows you to put a JavaScript-operated car showroom on any web page with one line of code. The original system was developed in mid-2003 and used syndication/AJAX technology before they were invented!

The AutoDirector widget code is something like: <div id="autodirector"></div> <script type=”text/javascript” src=”carlist.php?site=myshowroom”></script>

The JavaScript uses innerHTML to add HTML into the “autodirector” element. It works well, but I’ve always felt it could be better.

A brilliant article at SitePoint describes the issues and a solution that’s so obvious, I’m not aware of anyone using it before!

In effect, it proposes that you identify the calling <script> element, then use it as a reference in an insertBefore to inject HTML nodes into the DOM. It’s simple, effective, and clean. It means that the AutoDirector showroom widget code can be even shorter and avoid innerHTML as well as document.write.

  • categories: javascript
  • tags: dom, javascript
  • trackback: http://www.optimalworks.net/blog/2007/web-development/javascript/javascript-in-place-updates/trackback
  • bookmark: del.icio.us, digg, facebook, reddit, Furl, Spurl, Blinklist, Slashdot, Technorati, Yahoo!
add your comments
please enter your name
please enter your email address - it will not be published anywhere
please enter your website address
please enter your comments (all are moderated and checked for spam)
  • next article: Apache 2, PHP, caching, and relative file path problems 
  • previous article: Using CSS to create Vista-like Aero effects 
search
  • all popular (5)
  • courses (1)
  • general (3)
  • hardware (1)
  • software (24)
    • free download (6)
    • web browsers (9)
    • web servers (2)
  • web development (31)
    • accessibility (4)
    • ajax (1)
    • css (2)
    • graphic design (4)
    • html (1)
    • javascript (7)
    • php (4)
    • seo (1)

tags

  • accessibility
  • ajax
  • apache
  • award
  • computing
  • css
  • design
  • developers
  • dom
  • download
  • editor
  • firefox
  • funny
  • graphics
  • hardware
  • html
  • ie
  • javascript
  • opera
  • php
  • portfolio
  • review
  • safari
  • seo
  • server
  • software
  • ssl
  • standards
  • wordpress
  • xml
  1. site map
  2. home
  3. Services
  4. Portfolio
  5. Contact us
  6. blog
  7. RSS feed
  8. project survey

XHTML 1.0 | CSS 2.1 | WAI AAA | printer-friendly

©2008 Optimalworks Ltd, Devon, UK. Registered in England and Wales No. 5922205.

This page can be viewed at http://www.optimalworks.net/blog/2007/web-development/javascript/javascript-in-place-updates