472,780 Members | 1,247 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 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 5280
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.