471,310 Members | 1,385 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

embedded html page

Hi,

I have an embedded HTML object as follows (ignore the code tag):

<code>
<object id="page" data="table.html" type="text/html" .... >
</code>

I look for the Javascript code (placed in the main document) that can reload
or refresh the object contains at will?

Thanks for any idea!
Moist


Jul 23 '05 #1
6 2199


Moist wrote:

I have an embedded HTML object as follows (ignore the code tag):

<code>
<object id="page" data="table.html" type="text/html" .... >
</code>

I look for the Javascript code (placed in the main document) that can reload
or refresh the object contains at will?


Consider using an iframe e.g.
<iframe name="iframeName" src="table.html"></iframe>
that way you can in all browsers script
window.frames.iframeName.location.reload();
Refreshing an <object> is difficult across browsers, recent Opera and
Netscape/Mozilla version allow you to access the contentDocument
property of the HTMLObjectElement element object and then you can access
the defaultView and from there the location object:

<object id="object1"
type="text/html"
data="test2004090402.html">
width="200" height="200"></object>
<input type="button" value="refresh"
onclick="var object = document.getElementById('object1');
if (object.contentDocument &&
object.contentDocument.defaultView &&
object.contentDocument.defaultView.location) {
object.contentDocument.defaultView.location.reload ();
}">
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

"Martin Honnen" <ma*******@yahoo.de> a écrit dans le message de news:
41***********************@newsread4.arcor-online.net...


Moist wrote:

I have an embedded HTML object as follows (ignore the code tag):

<code>
<object id="page" data="table.html" type="text/html" .... >
</code>

I look for the Javascript code (placed in the main document) that can
reload or refresh the object contains at will?
Consider using an iframe e.g.
<iframe name="iframeName" src="table.html"></iframe>
that way you can in all browsers script
window.frames.iframeName.location.reload();
Refreshing an <object> is difficult across browsers, recent Opera and
Netscape/Mozilla version allow you to access the contentDocument property
of the HTMLObjectElement element object and then you can access the
defaultView and from there the location object:

<object id="object1"
type="text/html"
data="test2004090402.html">
width="200" height="200"></object>
<input type="button" value="refresh"
onclick="var object = document.getElementById('object1');
if (object.contentDocument &&
object.contentDocument.defaultView &&
object.contentDocument.defaultView.location) {
object.contentDocument.defaultView.location.reload ();
}">


Thanks for this info!
Frames is probably the simplest solution. But do you know if IE can access
embedded objects in a HTML page, or at least reload them. I've searched in
MSDN library with no success so far, I didn't see any methods that can do
that. May there is none... :(


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

Jul 23 '05 #3


Moist wrote:
"Martin Honnen" <ma*******@yahoo.de> a écrit dans le message de news:
41***********************@newsread4.arcor-online.net...

Moist wrote:
I have an embedded HTML object as follows (ignore the code tag):

<code>
<object id="page" data="table.html" type="text/html" .... >
</code>
But do you know if IE can access
embedded objects in a HTML page, or at least reload them.


IE can access the object elemens the same way as other elements, e.g.
var page;
if (document.getElementById) {
page = document.getElementById('page');
alert(page.data);
}
but in my tests it refuses to change the loaded data if you reassign to
the data property.
I haven't found a way to access the document inside of an embedded
<object> element with IE.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4
>>>>I have an embedded HTML object as follows (ignore the code tag):

<code>
<object id="page" data="table.html" type="text/html" .... >
</code>
But do you know if IE can access embedded objects in a HTML page, or at
least reload them.


IE can access the object elemens the same way as other elements, e.g.
var page;
if (document.getElementById) {
page = document.getElementById('page');
alert(page.data);
}
but in my tests it refuses to change the loaded data if you reassign to
the data property.
I haven't found a way to access the document inside of an embedded
<object> element with IE.


Using your code and trying 'location.href' instead, it seems to work:

object = document.getElementById('table');
object.location.href = "c:\\table.html";

It reloads the page I wanted to. However, as you said, accessing elements in
that page remains to be seen...

Moist
--

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

Jul 23 '05 #5

"Moist" <a@b.com> a écrit dans le message de news:
iz******************@weber.videotron.net...
>I have an embedded HTML object as follows (ignore the code tag):
>
><code>
> <object id="page" data="table.html" type="text/html" .... >
></code>
>
But do you know if IE can access embedded objects in a HTML page, or at
least reload them.


IE can access the object elemens the same way as other elements, e.g.
var page;
if (document.getElementById) {
page = document.getElementById('page');
alert(page.data);
}
but in my tests it refuses to change the loaded data if you reassign to
the data property.
I haven't found a way to access the document inside of an embedded
<object> element with IE.


Using your code and trying 'location.href' instead, it seems to work:

object = document.getElementById('table');
object.location.href = "c:\\table.html";

It reloads the page I wanted to. However, as you said, accessing elements
in that page remains to be seen...

Moist


I discovered even simpler, just by using the name of the object directly:

table.location.href = "c:\\table.html";

Moist
--

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


Jul 23 '05 #6
On Sun, 5 Sep 2004 13:01:28 -0400, Moist <a@b.com> wrote:

[snip]

Please trim quoted text that doesn't apply to your post.
I discovered even simpler, just by using the name of the object directly:

table.location.href = "c:\\table.html";


It will work in IE, but it is unlikely to work in other browsers. See:

<URL:http://jibbering.com/faq/#FAQ4_41>

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Aquarius2431 | last post: by
2 posts views Thread by FishingScout | last post: by
2 posts views Thread by Owen.Leibman | last post: by
1 post views Thread by jmc | last post: by

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.