You can also hide a text field on your web page (make sure it has the extension .irpt) like this:
<input id=localized name=localized type=hidden value={##LocalizationKey} />
This will put the value of the localized entry directly onto your page and you can reference it directly in JS or you can change the type field to be visible; works well for field labels. This is documented in the MII help here: http://help.sap.com/saphelp_mii151sp00/helpdata/en/4c/8c1960f2bd60c8e10000000a15822d/frameset.htm
Sam