Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Get iframe URL

  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Get iframe URL

    I have a web page with an iframe. This iframe's source is from a webpage that is not on my server. I want to get the url from the iframe (after say its been navigated a little bit so it isnt the original source) and store this url as a php variable named $variable for example (and if this isnt possible write the url to a mysql database)

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I don't see how you are going to be able to do this because you will need to reload the page to get the new iframe url but the default one will still be there not the new one. Javascript can't read the iframe url because its not on the same server as yours. You would some how need the external site to send back the url to a file on your server.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    reloading isnt a problem as long as i can get the iframe's url and then send it to the reloaded page and get it into a php variable (with a link or button to reload the page activating the script)

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    That is the problem. Reloading the page will put the same url in the iframe that the page originally started with, not the url that the user stopped on. There is no way to get the active url of the iframe. JS can't do it for security reasons and php won't know the iframe changed because again once the page reloads the iframe goes back to its default url.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    teh frames[0].location javascript will show the iframe's url, if i could add that to a link kind of like this http://mypage.com/blah.php?url=<javascript>

    then i could use a php $_GET to get the iframe's url, i just dont know how to input the javascript at the end of the link or if it would even work

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Yeah it will show the iframe url IF the url is on your own server. If its another website the javascript will error out for security reasons.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •