Well, I'm not a javascript expert so I don't know exactly why that isn't working. You're probably right that it's because the document hasn't loaded yet. But I'm not sure that having a user's browser load the page in a separate window every time one of those links is in a post is a good idea. Anyway, I did 5 minutes of research on the subject so I'm obviously not well informed, but it seems like there is a function that will create a new document from a url, but it's only in newer browsers. But without using that, I think you could parse it as XML or even just as a string, instead of loading it into a DOM object.
Doing a search for "open graph protocol parsers" I notice that there are parsers for php, so you might be able to figure out a server-side solution. Maybe when the post is being saved check it for one of those bbcodes and if it's found, parse the document for the og data and do a replacement. But I'm not sure what would happen if the user wanted to edit the post later.
|