This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

Friday, January 13, 2006

New Term: Macrodobe

Alex Russell just told me a great term (he heard it from Bob Ippolito) that I like: Macrodobe. Macrodobe is the strange, new hybrid beast (lumbering?) that is the combined Macromedia/Adobe merger. Watch out, or the Macrodobe will come to get you!

Dave Winer's Aggregator API

Dave Winer rolls an RSS Aggregator API, exposing it using XML-RPC. Very cool.

Easy Mashups With Parameterized Script Tags

While working with Rojo recently I was asked for a way to pass parameterized values into a script tag that would be used by third parties. There are several standard ways to do this (using global variables in a script block before you include the script; passing them in as query parameters on the script tag and have the values inserted by a server-side script; passing them in on the page location itself and have the JavaScript inspect its location), but I've been exploring a cleaner way that is much easier to read and is easier to write. Imagine if you could invoke a Yahoo Maps mashup this way from your web page:

<script longitude="200" latitude="500" src="http://www.yahoo.com/maps.js"></script>

I threw together a simple testing script and tested it cross browser and cross platform. This script tests being able to retrieve script tags by their ID, retrieving all script tags in the document, enumerating over them, and printing out two custom attribute values, "customAttribute1" and "customAttribute2". I tested the following browsers and they all worked: Firefox 1.4/Windows, IE 6/Windows, Safari 2.0/Mac, Firefox 1.5/Mac, and Opera 8.51.

The script is pretty straightforward:


test.html:
<html>
<head>
<script id="testScript"
customAttribute1="hello world"
customAttribute2="goodbye world"
src="test.js"></script>
</head>
<html>

test.js:
var byId = document.getElementById("testScript");
alert("byId="+byId);
var allScripts = document.getElementsByTagName("script");
alert("allScripts="+allScripts);
alert("allScripts.length="+allScripts.length);
var testScript = allScripts[0];
alert("testScript="+testScript);
var customAttribute1 = testScript.getAttribute("customAttribute1");
alert("customAttribute1="+customAttribute1);
var customAttribute2 = testScript.getAttribute("customAttribute2");
alert("customAttribute2="+customAttribute2);
This technique should help sites that want to turn themselves into a collection of decentralized web services that can be invoked and embedded; it can also help AJAX/DHTML libraries to easily pass in parameterized values, such as in Dojo. This can replace Dojo's djConfig static block, simply passing the values in when you pull dojo.js in:

<script src="dojo.js" dojoBase="." preventBackButtonFix="true"></script>

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]