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

后端 未结 4 715
谎友^
谎友^ 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:31

    As Aaron have already told you, browsers don't allow this, but there are ways around it. You'll need to create a small hack. Eugene Gladyshev has a post on it on his blog.

    0 讨论(0)
  • 2021-01-05 16:36

    As Aaron states, it is not allowed to interact between iframes, but you should take a look at easyXDM, it helps with cross domain communication in javascript:

    http://easyxdm.net/wp/

    Here is the example you might be looking for:

    http://easyxdm.net/wp/2010/03/17/sending-and-receiving-messages/

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-05 16:54

    No, the browser doesn't allow interacts between iframes that are not on the same domain at all.

    0 讨论(0)
提交回复
热议问题