Forum Moderators: open

Message Too Old, No Replies

Detect wrong frame? Page loads in to incorrect frame can we redirect?

         

JAB Creations

4:24 am on Apr 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know we can detect if a page is in a frame...but can we detect that it's in the correct frame? How would that work?

SpaceFrog

7:41 am on Apr 5, 2005 (gmt 0)

10+ Year Member



with parentNode.name?

kaled

11:19 am on Apr 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I played around with this problem a couple of years ago and gave up because I couldn't make it work reliably on all browsers (problems with infinite loops, etc.)

Having gained knowledge and experience, I would say it's probably not overly difficult but if you plan to reload into a new (correct) frameset, ensure that the method does not depend on frames/windows/documents being created or rendered in any particular order. I found Opera to be especially troublesome in this regard because its scheduling seemed totally random.

Kaled.

JAB Creations

11:58 am on Apr 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Frames have name="", they can also have id="" ... javascript can detect id so this is what has been running int he back of my head.

JAB Creations

11:59 am on Apr 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also is there a way we can detect if the referer (frame file that the frame page was loaded from) is being loaded from the same domain name?

SpaceFrog

2:11 pm on Apr 5, 2005 (gmt 0)

10+ Year Member



yes just split referrer url on a chosen word... and check elements of array ...

JAB Creations

2:31 pm on Apr 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Great! ... whats the code look like? O.o

SpaceFrog

6:41 am on Apr 6, 2005 (gmt 0)

10+ Year Member



this will entirely depend on what is the part of url you want to test, could you tell us a bit more?

JAB Creations

8:28 am on Apr 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let's say www.example.com/frame.html is the correct frame. We know how to check IF there is a frame that files are being loaded in to but we don't know if it's being loaded from OUR domain not if it's being say loaded from www.example2.com.

SpaceFrog

8:45 am on Apr 6, 2005 (gmt 0)

10+ Year Member



domain=parent.top.location.href
tabdomain=domain.split('\/')
alert(tabdomain[2])