If you do not want to use relative URLs, you can get the db name as follows:
var dbname = unescape(document.location.href).split('/')[2]
as your href looks like this: http://host:port/dbname/doc...
This is also used by jquery.couch.app.js code. Therefore, if you use it, it is available to you in the initialization code:
$.couch.app(function(app) { alert(app.db.name); });
source share