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.
我知道在同一个页面框架或父页面上,我可以通过任何方式访问某些内容,window.location但是是否有办法检查我是否在 iframe 中,如果是,则将顶部(父窗口)位置转到某个地方?
window.location
这是一个简单的代码来检查您的页面是否在 iframe 中加载:
if (window.location != window.parent.location) window.parent.location = "http://someurl";