Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只需要读取加载不同域的 iframe 的位置。 我不想改变它;我只想知道位置在哪里。 XSS 保护阻止我阅读location.host
location.host
我可以以任何方式获取 iframe 的位置吗?
不,除非您可以将自己的脚本注入 iframe。浏览器的同域策略可以防止这种情况。
如果您需要 iframe 的父 URL,请尝试使用document.referrer
document.referrer