embedded html page

M

Moist

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
 
M

Martin Honnen

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();
}">
 
M

Moist

Martin Honnen said:
Moist wrote:



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... :(
 
M

Martin Honnen

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

Moist

I have an embedded HTML object as follows (ignore the code tag):
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
 
M

Moist

Moist said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top