•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,580 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,295 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 14855 | Replies: 1
![]() |
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:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
or under:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
'name1' is the name of a <DIV> tag I am using for an image.
Any ideas, suggestions?
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:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
or under:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
•
•
•
•
<script language='JavaScript' type='text/javascript'>
bb = 0;
function test()
{
aa = document.body.scrollTop + 17;
//cc = window.event.x ;
bb -= aa;
bb *= 0.8;
bb += aa;
name1.style.top = bb+9;
}
setInterval("test()",20);
</script>
'name1' is the name of a <DIV> tag I am using for an image.
Any ideas, suggestions?
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/
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/
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Internet Explorer 2! (Windows Users Lounge)
- free php/mysql programming (Web Development Job Offers)
- JavaScript/DHTML newbie -- general questions (JavaScript / DHTML / AJAX)
- im new here (Community Introductions)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Remove style with JavaScript
- Next Thread: Javascript:How to transfer values between ASP.NET pages



Linear Mode