I have an iframe:
<iframe src="http://externaldomain.com/something.html">
If something.html from externaldomain.com has the css:
html { position: relative; }
In IE, it will render the iframe as blank. All other browser are fine.
Anyone know of a solution? Remember the same origin policy. I cannot alter anything within the iframe with javascript or change the css as the iframe src is external.
Thanks.
Use the following syntax it will work.
Give the style="position:relative;" to your iframe it will work in IE.
I would start by reading this Another Cross Domain iFrame Communication Technique and then look at a more elegant AJAX solution. I have seen a lot of situations where cross-domain iframes just don't work (and for good reason).
IFrames are one step above IE in the Axis of Evil (IMO)
As a workaround, if all else fails, you can download the contents of something.html using server-side logic, like ASP.NET or PHP, and save it on your local web-server somewhere. Then you can avoid the same-origin policy, or you can even modify the HTML/CSS yourself on the server, for ex., remove the offending position:relative.
iframe must have attribute ID
window.parent.document.getElementById('iframeid').contentWindow.document.execCommand('print', false, null);
Related
I am trying to iframe a website for some testing purposes. I have used a chrome extension that allows you to iframe any website. Problem is that with some websites I get the error about widevinecdm. Is it possible to let an iframe use widevinecdm from the chrome browser? Or is there a bypass or someway to get passes this error?
I found a doc for this: https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-permissions-in-cross-origin-iframes
Simply use the allow="encrypted-media *;" attribute on your iframe element, such as:
<iframe src="https://google.com" allow="encrypted-media *;"></iframe>
I hope this helps someone in the future.
So I need to get the body code of an Iframe, in javascript or Jquery or whatever to communicate with my server. I set up my iframe like this:
<iframe src="http://localhost:9090" name="frame" id="frame"></iframe>
and it displays what my http server sent to it just fine, but when I attempt to get the body of my website/HTTP server using this code:
var content=$("#frame").contents().find("body").html(); alert(content);
But it just returns nothing. PS I am using chrome
If your iframe is pointing at a page that is not from the same domain as the page that contains, then the Same Origin Policy will prohibit your page from reading the DOM of the iframe.
If you really have a pressing need to know the contents of the iframe, then use a library like CURL to load the same page on the server side.
Using Chrome or any other browser isn't the problem here. Same-origin policy is. This policy would prevent you to read the content of a site that is hosted at some other domain. Even proxy matters in this case.
You cannot just read the contents of Iframe by just loading it.
https://en.wikipedia.org/wiki/Same-origin_policy Read this to learn more about it.
I used to display web pages in iframes. But when I tried to display my stackoverflow user info in an iframe, it went wrong. The content is not getting displayed. What may be the possible reason (or reasons) for this behavior? How can I display my page in an iframe? Is it possible to display it in iframe with pure html or is there any need for javaScript or AJAX or something like that? If this is not possible, is there any workaround for this?
Here is a Live Demo.
A possible reason for this could be same as that of Google. As some sites do not allow their sites to be iframed.
To quote from #Daan:
Google uses an X-FRAME-OPTIONS HTTP header to disallow putting their pages in iframes: https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header
Could be a case with SO too.
I have an iframe on a page that I need to initially have a blank src for, as I eventually set the src with javascript.
I had been using a however have encountered an issue in Safari and Chrome where this loads a duplicate copy of my page within the iframe.
I read about "about:blank" in another question, however I've read that IE9 sends a null request to the server when you use this as the src. I've also yet to find anything listing this src as standards compliant.
Does anyone have an alternative to "about:blank" that they use to create an empty iframe?
about:blank is the way to do it. Alternately, you could just insert the whole <iframe> element with JavaScript later, and don't worry about a valid "empty" src.
One of the linkers in Google Web Toolkit contains a dynamically created iframe. They use javascript:'' as a temporary placeholder for the src attribute. The reason, according to the source comments, is "Prevents mixed mode security in IE6/7.".
Source.
As part of the about URI scheme standard, about:blank is probably the best option as it has very good browser support.
about:blank Returns a blank HTML document with the media type
text/html and character encoding UTF-8. This is widely used to load
blank pages into browsing contexts, such as iframes within HTML, which
may then be modified by scripts.
You can see further here
I'm trying to use the sample code on this page. I copy paste it into an html file and try to open it using IE9 and FF but nothing shows up. Any idea what I might be missing?
http://code.google.com/apis/youtube/iframe_api_reference.html#Getting_Started
One thing that can help is making sure your page is rendered in standards mode by declaring it as <!doctype html>. However, that does not seem to fix all circumstances where the embed fails to load. (For example, it also doesn't like to load if the containing element isn't displayed.)
Works for me only after deleting browser history.
So I'm guessing it may have something to do with resource de-allocation of some sort (although, I would expect the IE's Javascript interpreter to do it).