About InfoWorld : Advertise : Subscribe : Contact Us : Awards : Events : Store
InfoWorld HomeNewsTest CenterOpinionsProduct GuideTechIndex
 COLUMN ARCHIVE  FORUMS
 

COLUMN

 
Strategic Developer
Jon Udell

Revisiting the scriptable DOM

The scriptable DOM (Document Object Model) was always an intoxicating idea. Mobile scripts that lived in Web pages -- and could inspect and modify their hosts -- seemed rich with possibility. But when I saw the gymnastics those poor scripts had to perform in order to detect and adapt to browser versions, I recoiled in horror. There was no way I was going to use, or recommend, such a fragmented technology.

   ADVERTISEMENT
  

Free IT resource

TechNet: More ways to know it, share it, and keep it running.

Sponsored by Microsoft

Free IT resource

Attend the SOA Executive Forum: Breaking SOA Bottlenecks SOAExecForum.com/may2007

Sponsored by InfoWorld

RELATED LINKS
»  IT trainer offers master's degree for hackers
»  MSNBC buys participatory news site Newsvine
»  Merchants: eBay ad programs drive buyers away
»  Web services RSS feed 

IDG ENTERPRISE NETWORK
Web Services Caution Abounds  (CIO)

TOP NEWS 


IT SOLUTION SEARCH
Recently, though, my LibraryLookup project[1] has reacquainted me with the world of JavaScript and the DOM. I was pleasantly surprised to find that scripts I wrote in Mozilla, under Mac OS X, worked identically under MSIE 6 on Windows. This is great news! It means that we're now in a position to reap the benefits of a class of software I'll call "interactive service intermediaries."

Here's the example I came up with. Suppose your LibraryLookup bookmarklet reveals that your local library doesn't carry a book you're interested in. Many OPACs (online public access catalogs), including the one my library uses, enable you to request acquisition of the book. Filling out the form is a chore, though, so I wondered if I could use JavaScript to automate it.

The recipe for doing that involved three crucial ingredients. First, Amazon.com's pages consistently store title and author information in the first META tag, like so:

<META name="description" content="Guns, Germs, and Steel: The Fates of Human Societies, Jared Diamond">

Second, the browser's now-standard DOM makes that metadata easily accessible, like so:

var m0 = document.getElementsByTagName('META')[0]; var titleAuthor = m0.getAttribute('content');

In other words, get the object corresponding to the first metatag in the document, and then get the value of its "content" attribute.

Third, JavaScript's Perl-style regular expressions make quick work of capturing semistructured data -- in this case, separating the elements of the comma-delimited title/author value:

var re = /(.+),\s*([^,]+)$/; // define the regular expression

re.test(titleAuthor); // apply it

var title = RegExp.$1; // get everything before the last comma

var author = RegExp.$2; // get everything after the last comma

There's nothing new here, of course, but it's exciting to discover that it is finally possible to deploy such code with a high probability that it will work across browsers and operating systems.

Packaged as a bookmarklet, the script I wrote functions as an intermediary between Amazon and my library's OPAC. When I'm on an Amazon book page and I'd like to ask my library to acquire that book, I click the bookmarklet. It intermediates between Amazon, which from this perspective is an informational service, and the library, which can receive what is in effect a purchase order. The intermediation is interactive in the sense that the script does not directly transmit the purchase order, but rather presents it to me -- as a generated form -- for my approval.

Of course neither Amazon nor the library's OPAC is a formal XML Web service. But this principle of interactive intermediation will apply equally in that case. We think of Web services as a kind of application-to-application communication, and indeed they are, but we'll often want to involve people too. The scriptable DOM is turning out to be a great way to bring people into the loop.

1. http://weblog.infoworld.com/udell/stories/2002/12/11/librarylookup.html


Jon Udell is lead analyst at the InfoWorld Test Center. Contact him at jon_udell@infoworld.com and check out his Weblog at http://weblog.infoworld.com/udell.




RELATED SUBJECTS

Web Technologies


SPONSORED WHITE PAPERS
EMC - Lower costs and improve reliability-Get the EMC CLARiiON white paper!
Ciphertrust - Are you ready for Sobig.G? Learn how to protect your email systems.
CDW - Personal attention. CDW. The Right Technology. Right Away.
EMC - Explore key performance features and capabilities of EMC ControlCenter 5.1.1.
Intel - Free Intel white paper shows you how to deploy a secure wireless LAN
Cisco - FREE WHITE PAPER: BLUEPRINT to design and implement secure VPNs
Verity, Inc. - "Mass Consolidation Hits the Web-Search Market"
McDATA - Download a FREE storage consolidation white paper from McDATA(R).
Lucent Technologies - Overcoming Common Firewall Limitations
Lucent Technologies - Leverage Your Mobile High Speed Data Access. Download Free White Paper!
Nokia - Get the scoop! Mobilizing business white papers & case studies.
BMC Software - Maximize the Potential of Enterprise Data: Free white paper!
Network Associates - Free white paper - Strategies for Optimizing Network Costs and Benefits
Entrust - Manage identities across applications. Improve productivity.
Stalker Software - CommuniGate Pro - Transform your Email and Calendaring
Remedy - A NEW Gartner Research Note:Producing Quality IT Services

Search the IDG White Paper Library:


SPONSORED LINKS

INFOWORLD MARKETPLACE


» EMC delivers high-speed image capture, storage
Learn how you can quickly capture, organize, and deliver information with EMC ApplicationXtender.
» Agentless SOA Management
SOA operational visibility in less than a day, without installing message agents - free download.
» Apply BPM and ITIL at your IT Help Desk
ServiceWise brings BPM to complete IT service while eliminating integration cost. Learn more here.
» Find IT Consultant
Post Your Project for Free. Get Bids from Thousands of Pre-Screened Consultants. Register Now!
» Metadata Management Software
MetaCenter: Plug & play metadata management software for enterprise systems. Features: data ...




 HOME  NEWS  TEST CENTER  OPINIONS  PRODUCT GUIDE  TECHINDEX   About : Advertise : Subscribe : Contact Us : Awards : Events 

Copyright © 2008, Reprints, Permissions, Licensing, IDG Network, Privacy Policy

All Rights reserved. InfoWorld is a leading publisher of technology information and product reviews on topics including viruses, phishing, worms, firewalls, security, servers, storage, networking, wireless, databases, and web services.

Computerworld :: Network World :: CIO :: PC World :: Darwin :: CMO :: CSO
IT Careers :: JavaWorld :: Macworld :: Mac Central :: Playlist :: GamePro :: GameStar :: Gamerhelp
ITWorld Canada :: Computerwoche :: Techworld UK :: tecChannel :: IDG.se :: IDG.no