JavaScript - 检测跨域Iframe中的滚动条?

时间:2021-06-24 00:00:44

I'm loading a cross-domain page (that I have no control over) into an iframe.

我正在将一个跨域页面(我无法控制)加载到iframe中。

I want to know if this results in a scrollbar appearing in the iframe on my page or not.

我想知道这是否会导致滚动条出现在我页面上的iframe中。

I'm getting the impression that this just cannot be done (in Firefox at least), through any kind of direct detection or clever deduction, due to cross-domain security policies.

我得到的印象是,由于跨域安全策略,通过任何类型的直接检测或巧妙推演都无法完成(至少在Firefox中)。

Please only answer this question if you have direct experience successfully doing this yourself -- or trying everything and giving up.

如果您有自己成功做到这一点的直接经验 - 或者尝试一切并放弃,请回答这个问题。

(Those other discussions you want to refer me to don't work for cross-domain iframes with no control over the embedded page. And if you think jQuery must have something for this, please test it out first yourself to make sure.)

(你想引用我的那些其他讨论不适用于无法控制嵌入页面的跨域iframe。如果你认为jQuery必须有这方面的东西,请先自己测试一下以确保。)

TIA -- I don't have an SO account to respond to your answers. (do now)

TIA - 我没有SO帐户来回复您的答案。 (现在做)

1 个解决方案

#1


2  

It is not possible to do this because of the browser's security model. If it was possible, that would be a security problem and would have to be fixed. See my complete answer to this similar question for a more complete explanation.

由于浏览器的安全模型,无法执行此操作。如果可能,那将是一个安全问题,必须修复。有关更完整的解释,请参阅我对此类似问题的完整答案。

#1


2  

It is not possible to do this because of the browser's security model. If it was possible, that would be a security problem and would have to be fixed. See my complete answer to this similar question for a more complete explanation.

由于浏览器的安全模型,无法执行此操作。如果可能,那将是一个安全问题,必须修复。有关更完整的解释,请参阅我对此类似问题的完整答案。