Click to See Complete Forum and Search --> : using top.frames


liana
01-09-2003, 03:47 AM
Hy everybody!

I am trying to obtain in JavaScript the location information for a frame.
Actually, I have on my site a page that contains two frames as follows:

<html>
<frameset rows="80,*" border="0" frameborder="0" framespacing="0">
<frame src="http://mysite/mypage.htm" noresize scrolling=no name="home">
<frame src="http://www.google.com" scrolling=auto name="search">
</frameset>
</html>

I am trying to get access to the second frame (named search) - which contains a page located on a diffrent host - from the page displayed in the first frame (named home) which is on may host.
The source of mypage.htm is as follows:
<html>
<body>
<input type=button onclick="alert(parent.frames[1].location.href);" value="second frame location">
</body>
</html>

I can't succeed! The error message is "Access is denied".

If both of the pages are on the same host everything is ok!

All I want is to be able to obtain the location of the second frame.

Can enyone please explain to me why do I get the error? Is there a solution ?

Liana

gil davis
01-09-2003, 05:52 AM
Originally posted by liana
I am trying to get access to the second frame (named search) - which contains a page located on a diffrent host - from the page displayed in the first frame (named home) which is on may host. ...
I can't succeed! The error message is "Access is denied". ... Can enyone please explain to me why do I get the error? Is there a solution ?
This is a security "feature". Javascript is not allowed to access pages from another domain, because such action is considered a security violation. There is no solution. Sorry.

liana
01-09-2003, 06:12 AM
Thank you.