Grab URL of a Frame ?

Discussion in 'PHP' started by phantom, Nov 21, 2006.

  1. #1
    I have a page that consists of two frames.The lower fram has a name, "mainFrame". Is there a way to grab the URL of the lower frame (mainFrame) and store it in a variable?


    Any help or insight would be greatly appreciated.
     
    phantom, Nov 21, 2006 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    You could use a function like file_get_contents to get the whole page and then use a regular expression to find the url of that specific frame.

    It would be something like:
    
    
    $file = file_get_contents('http://www.mysite.com/mypage.html');
    
    $bottomFrame = preg_match('use some crazy regular expression');
    
    
    PHP:
     
    jestep, Nov 21, 2006 IP
  3. phantom

    phantom Well-Known Member

    Messages:
    1,509
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    140
    #3
    hmmmm What if I don't know what will be contained in the lower frame? Know what I mean. What if it is your site that I framed. How would I get the URL info and store it?
     
    phantom, Nov 21, 2006 IP
  4. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #4
    jestep is on the right track.

    Once you grab the page contents, you need to extract the <frame .... > tags.

    With the tag in hand, extract the name from name="name" portion of the tag and then extract the URL from the src="url" portion of the tag. You need to take into account of the possibility that the URLs will not contain the domain name.

    Those two pieces of information will allow you to associate names and URLs with the various sections of the page.
     
    clancey, Nov 22, 2006 IP