You are here: Re: xhtml style.left problem « HTML « IT news, forums, messages
Re: xhtml style.left problem

Posted by cwdjrxyz on 11/20/07 22:34

On Nov 20, 6:22 am, carex <ca...@skynet.be> 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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация