Do frames and iframes have isolated javascript contexts?

后端 未结 4 1081
孤街浪徒
孤街浪徒 2021-01-04 17:27

I\'ve made some experiments in Chrome but I\'m not sure so I need a confirmation :

Am I correct in thinking that iframes and frames have a separate JavaScript contex

4条回答
  •  囚心锁ツ
    2021-01-04 18:09

    The separation of context is not between frames, it is between domains. This means that if you load frame A with domain A and frame B with domain B, javascript from frame A cannot access domain B's context. Check this for a lengthier explanation.

    EDIT: Of course, if they 're on the same domain, the answer provided by SLaks fully applies.

提交回复
热议问题