js with <object> in xhtml strict

G

Grant Wagner

Simon said:
There are no <iframe> tag in xhtml strict, instead I should use
<object>.

If I change <iframe> to <object> then my javascript stops working.
I am curious to how to use <object> with javascript ?

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
<script type="text/javascript">
function reload() {
var el = document.getElementById("iframe");
el.contentWindow.location.reload();
}
var timer = null;
window.onload = function() {
timer = setInterval(reload, 4000);
}
</script>
</head>
<body>
<p>
Before
<iframe id="iframe" type="text/html" src="/content" width="330" height="57">
Blah
</iframe>
After
</p>
</body></html>

An <object> tag has no -src- attribute: <url:
http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3 />. Even if it did,
the <object> tag is not a window, so it doesn't have a -contentWindow-. The
<object> tag does have a -data- attribute, you can probably make use of that
fact.
 
S

Simon Strandgaard

There are no <iframe> tag in xhtml strict, instead I should use
<object>.


If I change <iframe> to <object> then my javascript stops working.
I am curious to how to use <object> with javascript ?



<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
<script type="text/javascript">
function reload() {
var el = document.getElementById("iframe");
el.contentWindow.location.reload();
}
var timer = null;
window.onload = function() {
timer = setInterval(reload, 4000);
}
</script>
</head>
<body>
<p>
Before
<iframe id="iframe" type="text/html" src="/content" width="330" height="57">
Blah
</iframe>
After
</p>
</body></html>
 
S

Simon Strandgaard

[snip xhtml]
An <object> tag has no -src- attribute: <url:
http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3 />. Even if it
did, the <object> tag is not a window, so it doesn't have a
-contentWindow-. The <object> tag does have a -data- attribute, you can
probably make use of that fact.


I am curious if its possible to reload an <object>, when its xhtml strict?


I have tried with the following code, where I use <object>.. but it doesn't
work.. what am I doing wrong?



<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
<script type="text/javascript">
function reload() {
var el = document.getElementById("iframe");
el.contentWindow.location.reload();
}
var timer = null;
window.onload = function() {
timer = setInterval(reload, 4000);
}
</script>
</head>
<body>
<p>
Before
<object id="iframe" type="text/html" data="/content" width="330"
height="57">
Blah
</object>
After
</p>
</body></html>
 
R

Randy Webb

Simon said:
Grant Wagner wrote:

Simon Strandgaard wrote:

[snip xhtml]

An <object> tag has no -src- attribute: <url:
http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3 />. Even if it
did, the <object> tag is not a window, so it doesn't have a
-contentWindow-. The <object> tag does have a -data- attribute, you can
probably make use of that fact.



I am curious if its possible to reload an <object>, when its xhtml strict?

Did you not read what Grant had to say? An object has a data attribute,
make use of it. Not that hard to test trying to change its data
attribute (just setting it back to itself, or, setting it elsewhere and
then back).
I have tried with the following code, where I use <object>.. but it doesn't
work.. what am I doing wrong?

Several things.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
<script type="text/javascript">
function reload() {
var el = document.getElementById("iframe");
el.contentWindow.location.reload();

objects have no contentWindow, read what Grant said.

Not a good idea to name your function "reload()" either. It conflicts
with the native reload() method.

el.data = "/content";
might be a place to start.
 
S

Simon Strandgaard

Randy said:
Simon said:
Grant Wagner wrote:

Simon Strandgaard wrote:


There are no <iframe> tag in xhtml strict, instead I should use
<object>.

If I change <iframe> to <object> then my javascript stops working.
I am curious to how to use <object> with javascript ?

[snip xhtml]

An <object> tag has no -src- attribute: <url:
http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3 />. Even if it
did, the <object> tag is not a window, so it doesn't have a
-contentWindow-. The <object> tag does have a -data- attribute, you can
probably make use of that fact.



I am curious if its possible to reload an <object>, when its xhtml
strict?

Did you not read what Grant had to say? An object has a data attribute,
make use of it. Not that hard to test trying to change its data
attribute (just setting it back to itself, or, setting it elsewhere and
then back).

Yes, I read it, but I cannot get (el.data = "someurl") working.
Im very interested in getting it working.

Several things.


objects have no contentWindow, read what Grant said.

Yes, I saw that. I have unsuccessfully tries with data.

Not a good idea to name your function "reload()" either. It conflicts
with the native reload() method.

el.data = "/content";
might be a place to start.


When I assign el.data to the URL, then nothing happens (Firefox +
Konqueror). Here is my code. I want to reload the <object>, but
don't know how?


<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
<script type="text/javascript">
function lets_refresh() {
var el = document.getElementById("iframe");
el.data = "/content";
}
var timer = null;
window.onload = function() {
timer = setInterval(lets_refresh, 4000);
}
</script>
</head>
<body>
<p>
Before
<object id="iframe" type="text/html" data="/content" width="330"
height="57">
Blah
</object>
After
</p>
</body></html>


Any help is appreciated.
 
M

Martin Honnen

Simon Strandgaard wrote:

When I assign el.data to the URL, then nothing happens (Firefox +
Konqueror). Here is my code. I want to reload the <object>, but
don't know how?

Use the latest version of Opera then, that can do it. Seriously, if you
want to embed a HTML document in one document and then be able to script
it better forget about <object> and use <iframe> instead, iframe is
rather consistently implemented in older and newer browsers while
<object> is a mess, in particular when it comes to scripting the loaded
document. I know that you want XHTML 1.0 strict which has no iframe but
if you want a solution that works across browsers <object> doesn't help
and you are better off with <iframe> and XHTML 1.0 transitional.
 
S

Simon Strandgaard

Martin said:
Use the latest version of Opera then, that can do it. Seriously, if you
want to embed a HTML document in one document and then be able to script
it better forget about <object> and use <iframe> instead, iframe is
rather consistently implemented in older and newer browsers while
<object> is a mess, in particular when it comes to scripting the loaded
document. I know that you want XHTML 1.0 strict which has no iframe but
if you want a solution that works across browsers <object> doesn't help
and you are better off with <iframe> and XHTML 1.0 transitional.

Ok, I suspected that this feature still wasn't fully supported yet.
Thanks for confirming this. If more people can confirm this then please do.

btw: <iframe> is much easier to search for than <object>.


if anyone has interest in what I need <object> or <iframe> for,
then have a look here:
http://ros.rubyforge.org/output/frontend/

comments still welcome :)
 
S

Simon Strandgaard

I have found a way, that works in Firefox.
(but doesn't work in Konqueror).


function lets_refresh() {
var el = document.getElementById("iframe");
el.contentDocument.location.reload();
}

<object id="iframe" type="text/html" data="/page.cgi" width="330"
height="57">
Blah
</object>


Im still interested in a solution that works in Konqueror.
If anyone happens to know this.. then please let me know.
 

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
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top