Singpolyma

Technical Blog

BlogID in Blogger BETA

Posted on

Blogger BETA seems to have no template tag (or equivalent) any more for the BlogID, which is sometimes a very useful value to have. I have hacked together the following JavaScript function which should return the BlogID of any Blogger BETA blog it is run on:

function getBlogID() {
var links = document.getElementsByTagName('link');
var href = '';
for(var i=0; i<links.length; i++) {
if(links[i].rel == 'EditURI') {
href = links[i].href;
break;
}//end if rel == EditURI
}//end for i<links.length
href = href.match(/blogID=([\d]+)/);
return href[1];
}//end function getBlogID

One Response

Johan Sundström

Is it really not available as data:blog.id? (Whether documented or not; did you try?) I vaguely recall I saw something to that effect when peeking through the code for the default widgets, in reverse-engineering the workings of the system that last hour before the real docs were published. 🙂

Definitely worth a shot if you didn’t try, and if you did and it didn’t work, I suppose I misremember (after all, there were id:s for most of the other things one would want id:s for, too).

It’s just something that seems too useful not to add and too easy to have to omit it, so it ought to be there, whether they consider it worth documenting or not.

Leave a Response