Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving url from an iframe

Status
Not open for further replies.

magicash

Programmer
Joined
May 29, 2005
Messages
3
Location
US
I would like to get the url inside of my iframe and post it in the "title" above that iframe. So if google.com was in the iframe, and I clicked links inside google, the title above would change to whatever url was inside the frame.

Passing the variable through php I used:
Code:
<script language="JavaScript">
 function setvariable()
{
test = parent.location.href;
document.write(test);
 }

 </script>
  <?php
 $x = "<script>setvariable()</script>";
  ?>
This correctly passes the main url. But if I change to parent.bottom.location.href(bottom is my iframe name) it just gives me a blank for the variable. Any ideas?

Thanks!
 

This will probably not be easy due to cross-domain security. There have been only a handful of threads where the poster has successfully managed to get cross-domain iframe reading working... and I'm not even sure that worked in any browser other than IE.

Have a search of the threads to see if you can find the posts I'm talking about.

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Hmm, well this is a tough problem I guess. Well, is there a way to open a new site if someone clicks a link inside that frame, or does this involve the same problem.

I'd like it so that if someone clicks a link inside the frame it will open up a new window with the url they clicked.

This is getting trickier that I thought.
 
I do not think you are going to get far due to privacy issues.

The only time I got around the cross-domain security issues was by using a HTA.

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
Ok I'll bite :) What is HTA?

-Chris
 

An HTA is an HTML Application. AFAIK, they work in IE only, but are more trusted than a standard web page (although why, or how much mor secure they are, I cannot tell you).

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top