Posts

Showing posts with the label iframe

Why is my iframe blocked by cross origin even it is not

Why is my iframe blocked by cross origin even it is not I have a <iframe> inside a <div> . My outer url is http://localhost:9090 and the src in iframe is http://localhost:9090/Server/v1 . In my outer context I have below code to access iframe dom: <iframe> <div> http://localhost:9090 http://localhost:9090/Server/v1 const f1 = window.frames[iframeName]; const iFrameHead = f1.document.getElementsByTagName("head")[0]; and I get an exception on the second line: Uncaught DOMException: Blocked a frame with origin "http://localhost:9090" from accessing a cross-origin frame. The reason I want to access ifame dom is that I need to insert a script into that iframe. The src in iframe has the same protocol, hostname and port number. What I don't understand is the iframe is on the same origin as the parent context. Why does it complain about the cross origin? After some debugging, I found there is because the iframe was redirected to a different ...

What is the difference between defaultcontent() and Parentframe() method in selenium webDriver?

Image
What is the difference between defaultcontent() and Parentframe() method in selenium webDriver? What is difference between below two methods : driver.switchTo().parentFrame(); driver.switchTo().defaultContent(); 3 Answers 3 As per the specifications, driver.switchTo().parentFrame(); invokes the following: driver.switchTo().parentFrame(); Where, the Switch to Parent Frame command sets the current browsing context for future commands to the parent of the current browsing context . As per the Java Docs parentFrame() method changes the focus to the parent context. If the current context is the top level browsing context, the context remains unchanged. As per the Java Docs , defaultContent() method selects either the first frame on the page, or the main document when a page contains iframes. That mean for example If i have 3 frames which are nested frames i1, i2, i3. I...

Iframes resizing to dynamic content

Iframes resizing to dynamic content I am trying to make my iframe resize itself to the content i put inside it. My problem is that it works as long as the content is longer but as soon as the content is shorter it does not become smaller. I have tried multiple solutions which don't work. Is it possible to refresh only the iframe component and not the whole page every x milliseconds? That might solve my problem. Edit 3* <head> function resizeIframe(objIframe) { objIframe = document.getElementById('myiframe'); objIframe.style.height = 'auto'; objIframe.style.height = obj.contentDocument.documentElement.offsetHeight + 'px'; } </head> <body> http://./home.php </body> No, your edit is worse than the first rev ( obj is undefined and document is the one your main page). And what you want is obj.contentDocument.documentElement.offsetHeight . – Kaiido 2 days ago ...