Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-29-2009, 07:16 AM   PM User | #1
VitruvianMan
New to the CF scene

 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
VitruvianMan is an unknown quantity at this point
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)
VitruvianMan is offline   Reply With Quote
Old 07-29-2009, 10:10 AM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 07-30-2009, 06:43 AM   PM User | #3
VitruvianMan
New to the CF scene

 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
VitruvianMan is an unknown quantity at this point
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)
VitruvianMan is offline   Reply With Quote
Old 07-30-2009, 07:25 AM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 07-31-2009, 04:46 AM   PM User | #5
VitruvianMan
New to the CF scene

 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
VitruvianMan is an unknown quantity at this point
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
VitruvianMan is offline   Reply With Quote
Old 07-31-2009, 08:06 AM   PM User | #6
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:11 PM.


Advertisement
Log in to turn off these ads.