JavaScript - Detecting Scrollbars in a Cross-Domai

2019-06-26 04:06发布

问题:

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

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

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.

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.)

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

回答1:

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.