execute javascript function in a another iframe when parent is from different domain

后端 未结 4 732
谎友^
谎友^ 2021-01-05 15:59

The page A.com has 2 iframes B.com/page1 and B.com/page2. This is the code of A.com:



        
4条回答
  •  长发绾君心
    2021-01-05 16:42

    Instead of

    parent.window.frames['iframe1'].SomeFunction(args);
    

    use

    parent.frames['iframe1'].SomeFunction(args);
    

    You are allowed to traverse the frames collection of any window that you can reference, but in this case you are trying to traverse the recursive window property of parent (which IS the window). This is not allowed.

提交回复
热议问题