Free Newsletters
Technology & Business Daily

InfoWorld
Log-in | Register
STRATEGIC DEVELOPER  

Revisiting the scriptable DOM

We can work across browsers and operating systems

By Jon Udell  
January 06, 2003
 

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.

Free IT resource

Open Source Business Conference (OSBC) May 22-23, 2007

Sponsored by OSBC

Free IT resource

Virtualization Insights from Top Experts - Learn how virtualization gets real!

Sponsored by Dell

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.
 

TOP NEWS:


»  Four quick tips for choosing an IM security product
71 percent of businesses will invest in real-time messaging this year. If you're one of them, be sure to protect your enterprise

»  Forrester analysts ID hot IT jobs
Research group finds 16 IT roles with a promising future

»  Nvidia claims 10 hours of HD video on Tegra chip
The Tegra 600 and 650 can be used with hard disk drives and are designed partly for mobile Internet devices

»  Database vendors add Google's MapReduce
Greenplum and Aster Data Systems will support Google's programming technique, developed for parallel processing of large data sets across commodity hardware

»  Network management: Tips for managing costs
New technologies, changing requirements, and ongoing equipment maintenance and upgrades cost money, but there are ways to manage expenses

»  EMC targets SMBs, branch offices with new low-end storage
Celerra NX4 highlights include thin provisioning, snapshot technology for data recovery and backups, and Web-based console for management of storage volumes




Remote Access: Maintain Security and Decrease the Burden on IT
Join this interactive webcast to discover how IT Managers can control access rights, end-user security settings and end-point authorization. Sponsor: Citrix(R) GoToMyPC(R) Corporate

»  Click here to view this Webcast
  Planning For A Disaster
This new, comprehensive Solutions Guide is your one stop source for Disaster Recovery. In it you'll learn how to reduce the likelihood of a disaster and to create a rock solid business continuity plan should you face a disaster situation. Sponsored by Equallogic

»  Click here to download now

- Special Advertising Partners -
WHITE PAPERS
 

» Technology White Papers Library

Technology White Papers by Topic

Technology White Papers E-mail Alert

Find out when the latest white paper is available:
 
 
INFOWORLD MARKETPLACE
 
» BUY A LINK NOW
 

FIND PRODUCTS AND COMPANIES
» COMPLETE PRODUCT GUIDE



TECHNOLOGY INDEX
• Applications
• Application Development
• Security
• Networking
• Wireless
• Platforms
• Hardware
• Data Management
• Storage
• Web Services
• Business
• Telecom
• Professional Services
• Standards

TECH WATCH 


What's the 411 on GOOG-411?
Just as Google has become synonymous with "performing a Web search," 411 is understood to mean "information" -- as in "what's the 411?" I was thus surprised to discover, from a billboard, no less, that the king of search is taking on the ...

Apple HTML source reveals 'iPhone Extreme'
"This one's a stretch..." reports AppleInsider. Um, yeah. Reporting on HTML code sightings of product names could be called a stretch, but iPhone Extreme has a ring to it. Now, that sounds like the product Apple should have released first, rather ...

COLUMNISTS

Unified under law
Ephraim Schwartz's Column and Blog (InfoWorld) - In the litigious world we live in, deploying a unified communications platform in your enterprise could...
» MORE COLUMNISTS

MORE INFOWORLD BLOGS


Open Sources 
Product Management
When I joined MySQL four years ago, there was quite a lot of debate about product management. We didn't actually have ...

Zero Day 
Botnet herders tending smaller flocks
New research backs up the theory that botnet operators are keeping their networks smaller in a continued effort to keep ...



• Advice Line
• Database Underground
• The Deep End
• Enterprise Mac
• Geeks in Paradise
• Grid Meter
• The Gripe Line
• InfoWorld Daily
• Inside IT
• IT Troubleshooter
• ITXtreme
• Open Sources
• ProdBlog
• Real World SOA
• Reality Check
• Security Adviser
• SMB IT
• The Storage Network
• Tech Watch
• Virtualization Report
• Zero Day

ADVERTISEMENT


RESOURCE CENTERadvertisement 

GOVERNMENT IT & POLICY
'If you don't go after the network, you're never going to stop these guys. Never.'
From the State Department, All the News for Inquiring Minds
TechPresident, the Internet Citizenry's New Consensus Taker



Sponsored Technology Links

 
 
 HOME  NEWS  BLOGS  PODCASTS  VIDEOS  TECHNOLOGIES  TEST CENTER  EVENTS  CAREERS   About | Advertise | Awards | RSS | Contact Us 

Copyright © 2008, Reprints, Permissions, Licensing, IDG Network, Privacy Policy, Terms of Service.
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.

CIO :: ComputerWorld :: CSO :: Demo :: GamePro :: Games.net :: IDG Connect :: IDG World Expo
Industry Standard :: IT World :: JavaWorld :: LinuxWorld :: MacUser :: Macworld :: Network World :: PC World :: Playlist