I would like to know if there is an alternative to iFrames with HTML5. I mean by that, be able able to inject cross-domains HTML inside of a webpage without using an iFrame.
相关问题
- how to get selected text from iframe with javascri
- How do you scroll an iframe from within using jque
- Is there any way to make the background of a 3D-mo
- Iframe scrollbar align to right
- I would like to manipulate the html inside an ifra
相关文章
- iframe的里内容看不到,但却点得到
- HTML5 control
- iframe content disappears on Firefox
- Changing an IFrames InnerHtml from codebehind
- Scrolling issues with ExtJS 5 app inside IFrame
- iframe not reading cookies in Chrome
- Does html5 local storage store per iframe?
- X-Frame-Options ALLOW-FROM a specific site allows
You can use object and embed, like so:
Which isn't new, but still works. I'm not sure if it has the same functionality though.
No, there isn't an equivalent. The
<iframe>
element is still valid in HTML5. Depending on what exact interaction you need there might be different APIs. For example there's thepostMessage
method which allows you to achieve cross domain javascript interaction. But if you want to display cross domain HTML contents (styled with CSS and made interactive with javascript)iframe
stays as a good way to do.If you want to do this and control the server from which the base page or content is being served, you can use Cross Origin Resource Sharing (http://www.w3.org/TR/access-control/) to allow client-side JavaScript to load data into a
<div>
viaXMLHttpRequest()
:Now for the lynchpin of this whole operation, you need to write code for your server that will give clients the
Access-Control-Allow-Origin
header, specifying which domains you want the client-side code to be able to access viaXMLHttpRequest()
. The following is an example of PHP code you can include at the top of your page in order to send these headers to clients:Although there isn't any perfect replacement I have been working on something, it's built be-be easy and I'm happy to say it works (thanks to junkfoodjunkie)
Basically, my current system uses some basic php/server combo to load and then save the file to the server, I just started up the project today so only the main file (such as index.html) is loaded. I'll be working to make it load 50 ish links from the page to help with support. If you would like to test it: it is hosted here. To use it is easy, just load the URL http://integratedmedia.ml/get/?link= and add your page to the end. no need to add in https or www. It will also cause problems if you do :) Anyways if you follow that set your copied page will be found at integratedmedia.ml/get/gettmp/YOURURL.html. Here is an example:
the downloaded file is now at
object
is an easy alternative in HTML5:You can also try
embed
: