Arash Dejkam wrote:
Is it possible to write on an <OBJECT type="text/html"> using
document.write() from within the html containing that tag the way we write
on a popup window? I couldn't do that after a lot of try.
You can do in Netscape 7, Mozilla and Opera 7 using the contentDocument
at least but it doesn't work in IE(5/6):
<html lang="en">
<head>
<title>the document object of an embedded object</title>
<script type="text/javascript">
function initObject () {
var object, objDoc;
if (document.getElementById && (object =
document.getElementById('anObject'))) {
if (object.contentDocument) {
objDoc = object.contentDocument;
}
else if (object.contentWindow) {
objDoc = object.contentWindow.document;
}
if (objDoc) {
initDoc(objDoc);
}
}
}
function initDoc (doc) {
doc.open();
doc.write([
'<html><head><title>document.written content<\/title><\/head>',
'<body><p>Kibology for all.<\/p><\/body><\/html>'
].join('\r\n'));
doc.close();
}
window.onload = function (evt) {
initObject();
};
</script>
</head>
<body>
<p>
Here is the object:
<object type="text/html" id="anObject"
width="200" height="200"
data="about
:blank"></object>
</p>
</body>
</html>
Can anyone report back whether the above writes to the object document
with Safari or Konqueror?
contentDocument is specified in the W3C DOM Level 2 HTML, see
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-38538621
so newer browser like Safari or Konqueror should support it.
But if you want to embed text/html and access its document then simply
go for
<iframe name="iframeName" ...></iframe>
and then you should have no trouble in browsers since IE4, Opera 6,
Netscape 6 etc accessing
window.frames.iframeName.document
with script.
--
Martin Honnen
http://JavaScript.FAQTs.com/