Iframe with auto highlight

I need to auto view iframe with cross domain src, I tried with javascript, but I get "Access Denied" when I try to get the height of the iframe contentWindow. anyone know any method?

+2


a source to share


3 answers


ItzWarty is right: the parent page cannot link to the child document, even to find out its height. Back in 2008, Michael Mahemoff published a detailed review of Cross-Domain Communication with IFrames , which may provide you with some guidance.

Hopefully along the way, however, HTML5 includes an improvement to this situation called " Multiple Document Transfer ", which is supported in Firefox 3, Safari 4, Chrome 2, Opera 9.2 and even IE ... 8. If your users are using only supported browsers, you can use it.

Perhaps you could set the scroll attribute on the IFRAME element to the default “auto” and test window.postMessage - if it succeeds, set the scroll to “no” and use the function to evaluate the IFRAME accordingly.



I recently looked into a similar issue (parent page from domain.tld creating page at blog.domain.tld), but I was able to use the "old document.domain hack " described by Mahemoff, although it is not supported in Opera.

Good luck.

+3


a source


If you created a proxy on your server that selected content, JavaScript will not have this limitation.



+1


a source


The domain problem is just one problem you're having - IE8 is another. Even though you can access the iframe, IE8 cannot get the body.clientHeight information for sure. Firefox works ...

+1


a source







All Articles