Web Analytics Made Easy -
StatCounter Pulling title from iframe cross domain - CodingForum

Announcement

Collapse
No announcement yet.

Pulling title from iframe cross domain

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pulling title from iframe cross domain

    Anyone know if there is a way to get the title string from an iframe src coming from another domain?

  • #2
    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()...
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

    Comment


    • #3
      looking into it. looks promising but haven't figured it out yet. will keep looking.

      Comment


      • #4
        any other suggestions? unable to get this to work

        Comment


        • #5
          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:
          Code:
          var theTitles = {
              "page2" : "Alligators",
              "page3" : "Bananas",
              ...
             };
          
          var theTitle = theTitles[ iframeSrcStrippedToNameWithoutExtension ];
          Be yourself. No one else is as qualified.

          Comment


          • #6
            Originally posted by wyclef View Post
            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...
            Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

            Comment


            • #7
              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?

              Comment

              Working...
              X