Re: xhtml style.left problem



On Nov 20, 6:22 am, carex <ca...@xxxxxxxxx> wrote:
Hello,

Since a few weeks I am trying to use xhtml i.s.o html everywhere in my web
application

But, for the first time, I have something that is working perfectly with
IE6 but not in Firefox when I use a DOCTYPE

Here below the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
<title>offset</title>
<script type="text/javascript">
//<![CDATA[
var delta=3;
function move(){
var y=document.getElementById("myDiv").offsetLeft;
if (y > screen.width - document.getElementById("myDiv").offsetWidth) {
delta=-3;
}
if (y < 0) {
delta=3;
}
y+=delta;
document.getElementById("myDiv").style.left=y;
document.getElementById("pos").innerHTML=y;
setTimeout("move()",30);
}
//]]>
</script>
</head>
<body onload="alert(document.compatMode);javascript:move()">
<div id="myDiv" style="position:absolute; left:50px; top:100px; width:200px; height:50px; background-color:blue;">
<h4>That's it damnit !!!(<span id="pos">pos</span>)</h4>
</div>
</body>
</html>

In Firefox, altough there is no error detected, the position is not
updated.
But if I remove the DOCTYPE then it works.

Is it a problem with Firefox ????

Thanks.
carex.

Others have shown some errors that caused the problem with Firefox,
and you apparently now have corrected your code so that it is working
for Firefox. However a problem remains if you still are using a xhtml
Doctype. No IE browser will support xhtml of any version if properly
served as application/xhtml+xml. You just get an error message. You
have to resort to some tricks, dual codes, etc to get the code to work
on IE. If your code is working on IE, you are not serving it properly
as xhtml. Rather, despite the Doctype, you are just serving it as
html. On the server you have to associate an extension such as .xhtml
with the mentioned mime type for xhtml, since the extension .html is
already associated with the mime type for html on most servers, and if
you want the code to work on IE you also have to resort to some
tricks, often involving a server side code such as php, so IE browsers
see html code, not xhtml code. Mis-serving an xhtml page as html
usually works, but all of the xhtml code is useless, and you would do
better to write the page as html 4.01 strict. If you do not serve your
pages properly as xhtml and do something to handle IE, then rewriting
your code in xhtml is useless and only wastes your time. I do write
and serve many new pages in xhtml. However just writing valid xhtml
code is only the starting point. There is much work to be done on
server side code, etc.

Many who post here do not think all of this is worth the effort, and
for a practical purpose, such as commercial web sites, they have a
point. However if you are as stubborn as I am and have much time to
invest, you likely can use and serve pages in xhtml properly for
browsers that support it and as html 4.01 strict for browsers such as
IE that do not.
.



Relevant Pages

  • Re: XHTML Problems
    ... to know whether it's HTML, XHTML, a flat file or dynamically generated, ... ..html suffixed link. ... There's one link, and the server provides what's needed, behind the scenes. ... their browser and my server can ...
    (comp.infosystems.www.authoring.html)
  • Re: XML Transformation Effectiveness.
    ... > I was actually looking for a server independant app like TiddlyWiki. ... > user to take the html document anywhere with them without being ... > The thing I want to do is very similar, accept I want to add an XML ... XML/XHTML), XHTML is a subset of XML. ...
    (comp.lang.javascript)
  • Re: insert text dynamically into textarea
    ... speed and server load. ... What do JS files have to do with the XHTML vs. HTML discussion? ... the older legacy PC browsers. ...
    (comp.lang.javascript)
  • Re: URL validation
    ... what is telling the server to serve as application/xhtml+xml (for the ... xhtml.php page) and as text/html. ... served as XHTML, ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: Why doesnt this work in Firefox?
    ... declare and validate against HTML 4.01 instead as XHTML ... Strict, XHTML 1.0 Strict and XHTML 1.1. ... Although recent Firefox version support `document.all' to a certain extent, ...
    (comp.lang.javascript)