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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to get URL from another frame.. Help!!!

Status
Not open for further replies.

BlondeLindsay

Programmer
Sep 19, 2001
6
GB
Hi all,

I have a page with 2 frames, one frame contains a webpage, any web page. The second frame needs to moniter Frame2's URL and log/act upon it.

Im really stuck

Any ideas??
 
it's an HTML (DOM related) problem
you can use javascript for example :
say your frames are named frame1 and frame2
say you want frame1 to monitor frame2
then write this in frame1 to retrieve the url of frame2 : the_other_frame_url=document.top.frame2.document.location
or
the_other_frame_url=document.top.frame2.location
or
the_other_frame_url=top.frame2.document.location

(coz it depends on the browser you're targetting)

now the_other_frame_url contains the url of frame2, you can pass it to the server so that php is aware of it
 
Hi,

Im a little new to this, your advice was great!!!, but I still cant get it to work. Could I email you my code, if thats not too much trouble that is.

Thanks a lot, I really appreciate it

Lindsay
 
just imagine, someone has the same problem as you do, and finds your question in the forum - s/he'll expect the answer to be here along with the question. That's why i'll be glad to answer you here but i won't help you by mail. What's more, in discussing here, some other people with maybe better ideas than mines can come and help.
please try to isolate the part of your code where frame1 tries to monitor frame2, and post it here, and we'll all see if we can help you.
 
Good point!

Here is my frameset code:

<frameset rows=&quot;80,*&quot; frameborder=&quot;NO&quot; border=&quot;0&quot; framespacing=&quot;0&quot;>
<frame name=&quot;Frame1&quot; scrolling=&quot;NO&quot; noresize src=&quot;Frame1.htm&quot; >
<frame name=&quot;Frame2&quot; src=&quot;</frameset>

Here is the script code from Frame1.htm:

<script LANGUAGE=&quot;JavaScript&quot; >
the_other_frame_url=document.top.Frame2.document.location;
document.writeln(the_other_frame_url);
</script>


When I run the frameset.htm the Yahoo page loads, but nothing happens in frame1

Its probably just some silly error, but im a newbie im afraid :)

Thanks a lot for the reply btw!

Lindsay
 
this is weird
try this :
<script LANGUAGE=&quot;JavaScript&quot; >
the_other_frame_url=top.Frame2.location;
alert(the_other_frame_url);
</script>
(it's netscape specific but i think it can work under ie)
do you see a pop up window with &quot;yahoo.com&quot; in it ??
 
Ah.. the alert works, i tried it with just &quot;hello&quot;... it mustnt be getting the &quot;other_frame_url&quot; value.

 
AND.. it works if i put &quot;Frame1&quot; instead of &quot;Frame2&quot; in your code.
 
i've just tried you url and it says : &quot;can't convert the_other_frame_url to string&quot; - this is weird ! i've never seen this error yet !! maybe it's a security issue (you can't play with other domains, it's tough to have 1 frame in 1 domain and the other one in another domain) - to see if it's the case, try to put anyfile.htm in frame2 (anyframe.htm belonging to your domain), and run the same code - then if you're using nn, type &quot;javascript:&quot; in the url bar and let me know what the console tells you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top