简体   繁体   中英

How to set focus on an iframe that is cross-domain

Similar to the posts below:

  1. Set focus on iframe in Chrome

  2. Setting focus to iframe contents

From the root/parent I want to be able to pass focus to the iframe.

Anything that may be in focus in the iframe is fine.

iframe.contentWindow.focus();

However, the iframe.contentWindow is not accessible because its a cross-origin frame.

Seems like the answer is: not possible.

If there is a script running in the iframe you can directly call focus from there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM