The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
A BB Code to use og: metas
Folks-
I want to use the og: data to display links to external pages. I thought I could make a BB code that uses javaScript to go get the info. It turns out I can't (at least without some help). It has been many ears since I tried to write javascript—and I'm really rusty. First, I tried: Code:
function getMetas (theURL){ var theTarget = new document() theTarget.location.href = theURL alert(theTarget.location.href) if(theTarget.document.getElementsByName("meta").length>0){ alert("meta tags "&& theTarget.document.getElementsByName("meta").length) }else{ alert("no meta tags") } } When I tried: Code:
function getMetas (theURL){ var theTarget = window.open() theTarget.location.href = theURL alert(theTarget.location.href) if(theTarget.document.getElementsByName("meta").length>0){ alert("meta tags "&& theTarget.document.getElementsByName("meta").length) }else{ alert("no meta tags") } } Am I missing something small or am I on a fool's errand? Any helpful hints you can share? |
#2
|
|||
|
|||
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. |
#3
|
|||
|
|||
Quote:
Quote:
Quote:
Thaks for your help. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|