Can scripts in iframe interact with scripts in the main page

前端 未结 5 2111
遥遥无期
遥遥无期 2021-01-13 06:03

I have an editor with an SWF multi-image uploader. Since not everyone will need to upload pictures in their article, i need to dynamically load this image uploader when nece

5条回答
  •  盖世英雄少女心
    2021-01-13 06:50

    If they are on the same domain, yes.

    The parent object is the parent window of the iframe.

    If you had a variable a in the global scope of the parent window, you could manipulate it in the iframe like this:

    parent.a = "new value";
    

    Similarly, if a is a function in the global scope of the parent window, you could call it like this:

    parent.a(args);
    

提交回复
热议问题