I am trying to find a way to load XHTML content in an Iframe.
I use to do this in html by using the following code :
var iframeObject = document.create Element("iframe ");
MyDiv.appendChi ld(iframeObject );
var data =
"<html><head><t itle>testing</title></head><body>data </body></html>"
iframeObject.co ntentDocument.o pen();
iframeObject.co ntentDocument.w riteln(data);
iframeObject.co ntentDocument.c lose();
This works fine. I can create my content dynamicly and synchroniously.
No problem.
No I try to switch to XHTML, but have trouble getting th eiframe to
understand that it gets XHTML data. It simply assumes that the data is
"text/html".
I tried to add the contentType with the .open() arguments:
var iframeObject = document.create Element("iframe ");
MyDiv.appendChi ld(iframeObject );
var data = "<!DOCTYPE html PUBLIC \"-//W3C//DTD ..etc..
transitional.dt d\">"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\" > etc etc </html>";
iframeObject.co ntentDocument.o pen("applicatio n/xhtml+xml", true);
iframeObject.co ntentDocument.w riteln(data);
iframeObject.co ntentDocument.c lose();
The code runs but the content is not seen as xhtml, so I can't mix html
and xml. Someone gave me the hint to use the following:
iframeObject.sr c="data:applica tion/xhtml+xml,"+dat a;
This works, the data gets loaded and is actually seen as xhtml, but..
the loading happens async in stead of sync.
Is there anyone who can help me with :
- does document.open(" application/xhtml+xml", true) work at all?
should it work ?
- are there other ways to wait for an async loading in scripting ?
Kees
I use to do this in html by using the following code :
var iframeObject = document.create Element("iframe ");
MyDiv.appendChi ld(iframeObject );
var data =
"<html><head><t itle>testing</title></head><body>data </body></html>"
iframeObject.co ntentDocument.o pen();
iframeObject.co ntentDocument.w riteln(data);
iframeObject.co ntentDocument.c lose();
This works fine. I can create my content dynamicly and synchroniously.
No problem.
No I try to switch to XHTML, but have trouble getting th eiframe to
understand that it gets XHTML data. It simply assumes that the data is
"text/html".
I tried to add the contentType with the .open() arguments:
var iframeObject = document.create Element("iframe ");
MyDiv.appendChi ld(iframeObject );
var data = "<!DOCTYPE html PUBLIC \"-//W3C//DTD ..etc..
transitional.dt d\">"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\" > etc etc </html>";
iframeObject.co ntentDocument.o pen("applicatio n/xhtml+xml", true);
iframeObject.co ntentDocument.w riteln(data);
iframeObject.co ntentDocument.c lose();
The code runs but the content is not seen as xhtml, so I can't mix html
and xml. Someone gave me the hint to use the following:
iframeObject.sr c="data:applica tion/xhtml+xml,"+dat a;
This works, the data gets loaded and is actually seen as xhtml, but..
the loading happens async in stead of sync.
Is there anyone who can help me with :
- does document.open(" application/xhtml+xml", true) work at all?
should it work ?
- are there other ways to wait for an async loading in scripting ?
Kees
Comment