By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

Write on <OBJECT type="text/html"> ?

P: n/a
Hi All,

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.

Thanks in advance.
Jul 23 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Arash Dejkam wrote:
Hi All,

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.

Thanks in advance.


Remember, you can use single quotes as well.

document.write("<OBJECT type='text/html'>")
| |
Single quotes----------------+---------+

Don't cross-post, please.
Jul 23 '05 #2

P: n/a

"Will Gittoes" <As********@NoSpam.org> wrote in message
news:10***************@radsrv1.tranzpeer.net...
Arash Dejkam wrote:
Hi All,

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.

Thanks in advance.


Remember, you can use single quotes as well.

document.write("<OBJECT type='text/html'>")
| |
Single quotes----------------+---------+

Don't cross-post, please.


You didn't get the point.
I don't want to write on my html but on the object frame itself, something
like this:

<object id="foo" type="text/html" />
<script>
foo.document.write("Hello World!");
</script>
Jul 23 '05 #3

P: n/a
> Arash Dejkam wrote:
Hi All,

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.

Thanks in advance.


Yes it is possible to output any type of mark-up at run-time using document.write.

--
Robert Collyer
www.webforumz.com
Free Web Design and Development Help, Discussions, tips and Critique!
ASP, VB, .NET, SQL, CSS, HTML, Javascript, Flash, XML, SEO !
Jul 23 '05 #4

P: n/a
Will Gittoes wrote:
Arash Dejkam wrote:
Hi All,

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.

Thanks in advance.


Remember, you can use single quotes as well.

document.write("<OBJECT type='text/html'>")
| |
Single quotes----------------+---------+

Don't cross-post, please.


or

document.write("<OBJECT type=\"text/html\">")
| |
forces the character following to be ignored

--
x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
Jul 23 '05 #5

P: n/a
"Arash Dejkam" <de****@softhome.net> wrote in
news:2m************@uni-berlin.de:

"Will Gittoes" <As********@NoSpam.org> wrote in message
news:10***************@radsrv1.tranzpeer.net...
Arash Dejkam wrote:
> Hi All,
>
> 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.
>
> Thanks in advance.
>
>


Remember, you can use single quotes as well.

document.write("<OBJECT type='text/html'>")
| |
Single quotes----------------+---------+

Don't cross-post, please.


You didn't get the point.
I don't want to write on my html but on the object frame itself,
something like this:

<object id="foo" type="text/html" />
<script>
foo.document.write("Hello World!");
</script>


What exactly are you trying to achieve?

There must be a better way, than the way you are approching this.

--
Robert Collyer
www.webforumz.com
Free Web Design and Development Help, Discussions, tips and Critique!
ASP, VB, .NET, SQL, CSS, HTML, Javascript, Flash, XML, SEO !
Jul 23 '05 #6

P: n/a


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/

Jul 23 '05 #7

P: n/a
Thanks Martin!

bad news it doesn't work in IE!, by the way, I tested your code in Opera
7.01 Build 2651 and it DIDN'T work! but worked in mozilla. I can't use
IFRAME because my page should be XHTML1.0 Strict.

Arash

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:40********@olaf.komtel.net...


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/

Jul 23 '05 #8

P: n/a


Arash Dejkam wrote:

bad news it doesn't work in IE!, by the way, I tested your code in Opera
7.01 Build 2651 and it DIDN'T work!
One reason more to go for the iframe. Sorry for not being more specific
about Opera, I had only tested with Opera 7.50 on Windows and as I don't
use <object> myself to render text/html I had no knowledge about details
of Opera support for contentDocument.

but worked in mozilla. I can't use
IFRAME because my page should be XHTML1.0 Strict.


It is your decision, if that document type is important to you then you
can't use iframe but currently with the browsers around if you are
interested in consistent and reliable use and scripting then iframe is
much better than object.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #9

P: n/a
DU
Martin Honnen wrote:


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) {

contentWindow can not apply to HTML object element
http://msdn.microsoft.com/workshop/a...tentwindow.asp

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();

or

var objParg = doc.createElement("p");
objParg.appendChild(doc.createTextNode("Kibology for all."));
doc.body.appendChild(objParg);
since blank document have a body node.
}

window.onload = function (evt) {
initObject();
Isn't that asking for trouble? Like asynchronous onload events for
window and document body?
};

DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Mozilla 1.7.3 :)
Jul 23 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.