View Full Version : Pulling title from iframe cross domain

08-18-2011, 08:12 PM
Anyone know if there is a way to get the title string from an iframe src coming from another domain?

rnd me
08-18-2011, 08:36 PM
you can get the .src attrib , but title sound more like it's coming from the document itself, which historically, you can't reach.

if you own the iframe'd page, you can add message passing events to respond to queries from the framing page. look into window.postMessage()...

08-18-2011, 11:53 PM
looking into it. looks promising but haven't figured it out yet. will keep looking.

08-21-2011, 02:56 AM
any other suggestions? unable to get this to work

Old Pedant
08-21-2011, 04:16 AM
Unless you have hundreds of possible <iframe> contents, why not just set up a table of correspondence between the .src of the <iframe> and the <title> of it?

That is:

var theTitles = {
"page2" : "Alligators",
"page3" : "Bananas",

var theTitle = theTitles[ iframeSrcStrippedToNameWithoutExtension ];

rnd me
08-21-2011, 08:10 AM
any other suggestions? unable to get this to work

you can use YQL to fetch html from almost any page.
just grab the title element, and use the json w/callback flavor YQL output...

08-21-2011, 04:11 PM
i think the yql/json option may be out of my league but what old pedant is talking about could work. i only have about a dozen or so iframe src. could you elaborate on this table of correspondence?