Click to See Complete Forum and Search --> : URL's in FRAMES


jartalo
09-24-2003, 11:11 AM
Hello,

I'm having problems with frames. I don't know if what I want is possible to do.

It's easy to order a frame a URL to load any url, with this sentence:

top.frames['frm_1'].document.location.href=url

but ¿is it possible to do just the opposite? that is, I have a page with 2 frames, frm_1 and frm_2. In frm_1 there is loaded 1.html, and in frm_2 is loaded, for example, http://www.google.com. Well, now, I don't want to say frm_2 to load anything, but want to know what URL is loaded in frm_2. I've tried this code unsuccessfully:

function anyfunction(){

var urlframe1;

urlframe1=top.frames['frm_2'].document.location.href;

alert(urlframe1);

}


and after: <a href="javascript:anyfunction()">click here to know where you are surfing in the other frame</a>. This code should be in 1.html.

¿Anybody can help me, please?

Thanks, and sorry for my english.

Charles
09-24-2003, 12:01 PM
JavaScript has several built in security features and one of them puts up a wall between documents from different domains. Unless both pages are from the same domain you will not be able to do this.

Khalid Ali
09-24-2003, 12:07 PM
If the frame 2 has a url loaded which is out of domain( such as google.com inthis case),
you can not access to the document.That will be the security breach.

You can only access resources which are being served fromyour own domain.

Edit
Cripes..I opened the thread and then moved away for few mins ,came back responded to it, only to find out that Charle's already has...:D

jartalo
09-24-2003, 01:57 PM
Thanks a lot.