简体   繁体   English

在iframe中查找具有其Id的元素位置

[英]Find element position inside iframe having its Id

I am using the below to get its position away from the Top 我正在使用下面的位置来远离Top

var posTop = document.getElementById('elementId').getBoundingClientRect().top 
- document.body.getBoundingClientRect().top

How is it possible to get its position if the element is inside an iframe and the iframe is not in the same domaine ? 如果元素在iframe中并且iframe 不在同一个域中,那么如何获得它的位置

you can access to other iframe just if the other domain accepted cross-origin. 只要另一个域接受了跨域,您就可以访问其他iframe。 so, if it's not your domain, you probably need to ask them to allow that, if possible 所以,如果它不是你的域名,你可能需要让他们允许,如果可能的话

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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