How to get URL of a Frame?

Discussion in 'JavaScript' started by phantom, Nov 19, 2006.

  1. #1
    How would I go about diplaying/getting the URL of a frame from another frame.

    All I want to do really is, while in 1 frame get the URL of another frame with javascript so I can use the data in php a script

    Thanks
     
    phantom, Nov 19, 2006 IP
  2. mani

    mani Peon

    Messages:
    679
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    is it a frame or IFrame? try giving a name to the frame and use the src property

    
      var framURL= frameName.src;
    
    Code (markup):
     
    mani, Nov 21, 2006 IP
  3. phantom

    phantom Well-Known Member

    Messages:
    1,509
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Yes it is a frame. The Frame's name is "mainFrame" So What I need to do is from the top frame, get the URL of mainFrame and store it in a variable for later use. Could you give me an example of how I would implement your code example in a script? I really am a javascript noob.

    Thank you in advance for your help.
     
    phantom, Nov 21, 2006 IP
  4. phantom

    phantom Well-Known Member

    Messages:
    1,509
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    140
    #4
    This is what I have so far but doesn't work. Any ideas?


    <script language="javascript" type="text/javascript">
    function geturl() {
            var mainurl = mainFrame.src;
     document.write (mainurl);
    }
    </script>
    
    
    
    <a href="javascript:geturl();" target="_blank">Report</a>
    Code (markup):
     
    phantom, Nov 21, 2006 IP