Click to See Complete Forum and Search --> : security problem with frames?
Poll Troy
12-30-2002, 05:53 PM
I have a page with two frames. I use top.frame1.location to get the url from frame1 to be used in frame2. This works fine as long as I use content from my domain in frame1. As soon as the content is from another domain, I get the information: top.frame1.location=undefined.
Is there any way to get around this probelm????
I also would like to stop the left mouse button in frame1. I guess this is the same problem?
Please help ASAP!!!
The reason this doesn't work is because when you use frames, the HTML that the frame uses is exactly the same as it would be if there were no frame. For instance, I could make a frameset with my site in the top frame and Yahoo! in the bottom one. I could do whatever I want to the top frame, but the bottom frame would still be Yahoo!'s page, whether or not my site calls it from a frameset. Make sence?
Poll Troy
12-30-2002, 06:03 PM
I am not 100% sure I understand you.
Actually, what I like to do is, I want toi update frame2 as soon as the content in frame1 is changed, regardless of wether the content is from a local html file or from another domain. I guess this is not possible in any way, using jsp, asp, php, cgi or anything else?
Thanks for the fast reply!
AdamBrill
12-30-2002, 06:40 PM
You can do this:
Put this in the body tag on the bottom page.
onload="top.frame1.document.location=top.frame1.document.location;"
Everytime that you refresh the bottom page, it will update the top page. This only works if you can edit the HTML in the bottom page, though...
Poll Troy
12-30-2002, 06:46 PM
What I want to do is the opposite, ie update the editable frame (frame2), when the content in frame1 is changed. I can only change the code in frame2. Frame1 is a forum that runs on another server.
Thanks again!
AdamBrill
12-30-2002, 10:59 PM
Your <FRAMESET> should look something like this:
<Frameset COLS="40%,*">
<Frame Name="frame1" Src="page1.htm">
<Frame Name="frame2" Src="page2.htm">
</Frameset>
or something like that... :) Change it to this:
<script language=javascript>
function refresh()
{
top.frame1.location=top.frame1.location;
}
</script>
<Frameset COLS="40%,*">
<Frame Name="frame1" Src="page1.htm">
<Frame Name="frame2" Src="page2.htm" onload="refresh()">
</Frameset>
That should update frame1 everytime frame2 is reloaded. I hope that helps...
Poll Troy
12-30-2002, 11:33 PM
Thank you a lot!!!
So simle and yet so difficult to find out! It works perfectly!!!
I am ever thanksful for this! I have been trying like 10 h to find a solution, reading everything I could find regarding javascript, history.length, web fetching, timerout combined with comparing locations in frame etc.
If I ever can help you with something, let me know on dreamer_gbg@hotmail.com!
Thanks again :)