473,396 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
9 5332
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

"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
> 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
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
"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


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


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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: David D. | last post by:
Does the file extension matter when including a JavaScript file in an HTML page? Normally, one would include a JavaScript file in an HTML page using <script src="foo.JS" type="text/javascript">...
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
1
by: tilt | last post by:
Hello, I use an object element to replace the iframe element in ie, like this: <object id="x_obj" data="http://.../" type="text/html"> <iframe name="x_if" id="x_if"...
2
by: alxasa | last post by:
Hello, I am hoping someone can help me with this. I need a javascript function, which sits inside a <input type="text" name="firstname"> line of code. Now, if someone starts typing fine, but when...
1
by: mark | last post by:
Forgive me if this seems like a stupid question but I need help... I'm trying to do a simple online form that emails me the results from a few fields. Here is the code: <form...
7
by: Amzul | last post by:
hello all. can someone tell if its possible to put <strong> inside the value? whats the right syntax? and another Q is it possible to applay new style to a form i mean i want to disable all...
3
by: joe | last post by:
Is it OK to have multiple: <script type="text/javascript" src="funcs1.js"></script> <script type="text/javascript" src="funcs2.js"></script> <script type="text/javascript"...
2
by: Warren Tang | last post by:
Hello, everyone Can I make a <input type="text"tag transparent? I mean I can see through it and see the background of its container. Regards Warren
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.