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

Object tag to write HTML page to via JavaScript?

P: n/a
gsb
Object tag to write HTML page to via JavaScript?

I've used iFrames and Objects to load web pages into another page.
I want to do similar but not load a uri, rather write the page, <HTML>
....to...</HTML> via a JavaScript function.
Is this possible with either of these two tags?

Thanks,

gsb
Jul 20 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
"gsb" <gs*@QWest.net> writes:
Object tag to write HTML page to via JavaScript?

I've used iFrames and Objects to load web pages into another page.
I want to do similar but not load a uri, rather write the page, <HTML>
...to...</HTML> via a JavaScript function.
Is this possible with either of these two tags?


Use an iframe.
---
<iframe id="foo" name="foo"></iframe>

<script type="text/javascript">
function writeDoc() {
var doc = frames['foo'].document;
doc.open();
doc.write("<!DOCTYPE ... ><html> ....funny content! </html>");
doc.close();
}
</script>
<input type="button" value="insert" onclick="writeDoc()">
---
Tested in IE 6, Mozilla FB and Opera 7.
Mozilla is the one that requires the name attribute on the iframe
in order to access it through the frames collection.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
gsb
Does that work with an object, or just an iFrame?

Thanks again,

gsb

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:oe**********@hotpop.com...
"gsb" <gs*@QWest.net> writes:
Object tag to write HTML page to via JavaScript?

I've used iFrames and Objects to load web pages into another page.
I want to do similar but not load a uri, rather write the page, <HTML>
...to...</HTML> via a JavaScript function.
Is this possible with either of these two tags?
Use an iframe.
---
<iframe id="foo" name="foo"></iframe>

<script type="text/javascript">
function writeDoc() {
var doc = frames['foo'].document;
doc.open();
doc.write("<!DOCTYPE ... ><html> ....funny content! </html>");
doc.close();
}
</script>
<input type="button" value="insert" onclick="writeDoc()">
---
Tested in IE 6, Mozilla FB and Opera 7.
Mozilla is the one that requires the name attribute on the iframe
in order to access it through the frames collection.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:

<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #3

P: n/a
"gsb" <gs*@QWest.net> writes:

Please don't top post.
Does that work with an object, or just an iFrame?


Probably only with iframes. It accesses the document object
of the embedded page throught the frames collection.

I don't have much experience with objects, but my impression is
that pages embedded with the object tag are not easily accessible
through scripting - because the object can hold so many different
types of data, there is no simple way to access the data that is
there.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4

P: n/a
gsb
I appreciate your patience, but I'm not sure what "Please don't top post."
means.
Please explain. I apologies for my ignorance regarding the posting.

I like the simplicity of your solution, but it did not work in Netscape (I
have 7.1)
That is why I asked about the object tag.

Thanks,

gsb
"gsb" <gs*@QWest.net> wrote in message
news:Ci*****************@news.uswest.net...
Object tag to write HTML page to via JavaScript?

I've used iFrames and Objects to load web pages into another page.
I want to do similar but not load a uri, rather write the page, <HTML>
...to...</HTML> via a JavaScript function.
Is this possible with either of these two tags?

Thanks,

gsb

Jul 20 '05 #5

P: n/a
"gsb" <gs*@QWest.net> writes:
I appreciate your patience, but I'm not sure what "Please don't top
post." means. Please explain. I apologies for my ignorance
regarding the posting.
Top posting refers to the practice of putting ones entire reply at
the top of the message, and including the entire previous message
below. It is a bad idea for several reasons.

1) Readability. While this can ofcourse be argued, a majority of
newsgroup users prefer to see the context of a reply before the reply.
Splitting the replies to different parts of the previous message up,
also makes it easier to see which reply replies to which part.

2) Bandwidth. Including the entire previous message below is a waste
of bandwidth. While a single message won't kill anyone, not even
people reading news on a modem and paying by the minute, if two people
both use this quoting style in reply to each other, the quotes would
quickly become huge (each message including the *entire* history of
the discussion). It is recommended to quote only the parts of the
previous message that are needed to give context to your reply.
Keeping quotes from even earlier messages is rarely improtant,
and should be kept to a minimum.
(Not quoting anything is also bad, because you completely lose the
context).

3) Structure. The standard for messages specifies a separator between
the message and the signature (minus-minus-space on a line of its
own). Message readers recognize this divider, and treats the part
below it specially. By writing the reply at the top, the entire quoted
message now appears below the signature separator, which can be highly
confuzing to both people and newsclients. The only advantage is that
clients should cut the signature before replying, potentially avoiding
the extra quoting. Sadly, not all clients does this.

Thank you for asking :)
I like the simplicity of your solution, but it did not work in Netscape (I
have 7.1)
It works for me in Netscape 7.1 (freshly installed - damn them for
installing AOL without my permission!).
That is why I asked about the object tag.


Actually, in Netscape 7.1 it seems to work with object instead of iframe.
It doesn't in Opera or IE, though.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6

P: n/a
gsb
Thank you for responding.
My internet express auto add that stuff in the reply.

Anyway, here's what I came up with:

function doWrite() {
var doc=null, obj=document.getElementById( "myID" );
if(obj.contentDocument) doc=obj.contentDocument;
else if(obj.contentWindow) doc=obj.contentWindow.document;
else if(obj.document) doc=obj.document;
// else I'm scewed - LOL
...
str = "whatever";
...
doc.open();
doc.write(str);
doc.close();
}

Works in IE6 and Netscape 7.1; don't know about the others.

Thanks for your help and patience.

gsb
Jul 20 '05 #7

P: n/a
In article <fz**********@hotpop.com>, Lasse Reichstein Nielsen <lr*@hotpop.com>
writes:
I like the simplicity of your solution, but it did not work in Netscape (I
have 7.1)


It works for me in Netscape 7.1 (freshly installed - damn them for
installing AOL without my permission!).


AOL or AIM? NS7 comes with the AOL IM service but I have never known it to
install the full blown AOL application.
--
Randy
Jul 20 '05 #8

P: n/a
JRS: In article <UV****************@news.uswest.net>, seen in
news:comp.lang.javascript, gsb <gs*@QWest.net> posted at Tue, 6 Jan 2004
20:31:25 :-
Thank you for responding.
My internet express auto add that stuff in the reply.


You chose to use it; it is for you to deal with its defects.

Before posting, it is advisable to read the FAQ with care.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #9

P: n/a
hi************@aol.com (HikksNotAtHome) writes:
AOL or AIM? NS7 comes with the AOL IM service but I have never known it to
install the full blown AOL application.


Actually, just an advertisment for AOL. I was thinking of AIM, but it
seems it worked to deselect it before installation. So, no that damn
was not deserved. Now they just get one for putting advertising on my
desktop :)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #10

P: n/a
Lasse Reichstein Nielsen wrote:
It works for me in Netscape 7.1 (freshly installed - damn them for
installing AOL without my permission!).


You are looking for http://www.holgermetzger.de/compactfaq.html
HTH

PointedEars
Jul 20 '05 #11

P: n/a
Lasse Reichstein Nielsen wrote:
It works for me in Netscape 7.1 (freshly installed -
damn them for installing AOL without my permission!).


You are looking for http://holgermetzger.de/net7compd.html
(other language packs are available).
HTH

PointedEars
Jul 20 '05 #12

P: n/a
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:
You are looking for http://holgermetzger.de/net7compd.html
(other language packs are available).


Does the page come in other languages too? :)
(Well, I can read German, it's just neither fast nor precise :)

I usually use Firebird anyway, so I'm not going to worry too much
about Netscape.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #13

P: n/a
Lasse Reichstein Nielsen wrote:
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:
You are looking for http://holgermetzger.de/net7compd.html
(other language packs are available).


Does the page come in other languages too? :)


If you like

<http://translate.google.com/translate?u=http://holgermetzger.de/net7compd.html&langpair=de|en&hl=en&ie=Unknown&oe= ISO-8859-1>

it does ;-)
PointedEars
Jul 20 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.