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

js with <object> in xhtml strict

P: n/a
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>
--
Simon Strandgaard
Jul 23 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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 ?

<?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>

--
Simon Strandgaard


An <object> tag has no -src- attribute: <url:
http://www.w3.org/TR/REC-html40/stru...ts.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.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #2

P: n/a
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/stru...ts.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>

--
Simon Strandgaard
Jul 23 '05 #3

P: n/a
Simon Strandgaard wrote:
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/stru...ts.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.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #4

P: n/a
Randy Webb wrote:
Simon Strandgaard wrote:
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/stru...ts.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.

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.


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.

--
Simon Strandgaard
Jul 23 '05 #5

P: n/a


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.

--

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

P: n/a
Martin Honnen wrote:
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.


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 :-)

--
Simon Strandgaard
Jul 23 '05 #7

P: n/a
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.

--
Simon Strandgaard
Jul 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.