Javascript; Accessing frameset frames from within other frames

前端 未结 1 1445
离开以前
离开以前 2021-01-22 20:15

I have a system in place which uses a frameset, within the frameset frames there are some calls like;

top.frame1.location = \"newlocation\"; 

a

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 20:58

    You are overwriting the value in top.frame1 with a jQuery set, which is NOT the same object as the default (which is a window object) which is why you are getting the "undefined" error - a jQuery set doesn't have a document property.

    If you want to fix this without changing all your references to top.frame1, then you have a couple choices. Assuming #containerframe is your iframe, I think this will work

    In your parent-most page

    frame1 = self.frames.containerframe.frames.frame1;
    

    EDIT

    The frames collection works off of name attributes, so make sure your iframe looks like this