954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

XHTML and javascript 'setInterval'

Hello,
I have got a problem.

In my forum software the DOCTYPE is for some reason set to XHTML

Now I have implemented a scroller using setInterval. This scroller works fine if there is no DOCTYPE specified or even if I specify it as HTML 4.01

The scroller does not work if the Doctype is XHTML.

Is there any reason for that? Why is that so? Which script do I have to use to make 'setInterval' work as it is supposed to?

here the script:
try it out under:

or under:


'name1' is the name of a tag I am using for an image.


Any ideas, suggestions?

Ann Drew
Newbie Poster
1 post since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

The DOCTYPE declaration informs the browser which particular "code flavor" your page uses. You can read about DOCTYPE's here:

http://htmlhelp.com/tools/validator/doctype.html

If you don't specify a DOCTYPE, the the browser will use it's defaults. In some cases, with IE for example, this means that you can get away with code that isn't strictly "correct". IE won't complain.

XHTML is very strict, intentionally. I prefer it because it forces me to write clean, tight code.

I don't see anything about your script that XHTML wouldn't like, at first glance. So there is probably something else on the page that isn't XHTML-friendly. You can use the following validator to troubleshoot your page:

http://validator.w3.org/

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You