Solved

Document Type Declaration causing onScroll event to not fire...

Posted on 2004-10-14
16
576 Views
Last Modified: 2013-11-19
When I use the following document declaration:

<!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" lang="en">

It will prevent the onScroll event in the <BODY> tag from firing.  However, when I remove this declaration it prevents me from using some of the more advanced CSS styles that our site requires.  Anyone know of a way to get the best of both worlds.



Side Note:  Thus far, I have to replace both those lines with just a <html> tag I can't replace one or the other...
0
Comment
Question by:Kamoku-Wan
  • 7
  • 5
  • 4
16 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
if you are actually using that spelling "onScroll " it will fail becasue events must be all lower case in xhtml.

If you are already using lower case then put the onscroll at the end of the script:

onscroll=yourfunction;
</script>

Cd&
0
 
LVL 3

Author Comment

by:Kamoku-Wan
Comment Utility
Yes I am using onscroll sorry I typed that up quick and didn't cut and paste.

I tried your idea of putting onscroll=yourfunction; at the end of my script with no luck.

It's as if that DTD blocks onscroll for some reason?
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 125 total points
Comment Utility
Hmmm...

According to:

http://www.blooberry.com/indexdot/html/tagpages/attributes/events.htm

Onscroll is not supported. within the standards.  However xhtml is the first DTD I have seen to enforce it.  

Cd&
0
 
LVL 3

Author Comment

by:Kamoku-Wan
Comment Utility
Ahh good catch.  Now can you perhaps offer me another DTD that might work for me?  The only CSS item I find that seems to mess up when I don't use this one is line-height.  It seems my designers can't live without their line-height... :-)
0
 
LVL 3

Author Comment

by:Kamoku-Wan
Comment Utility
I think I found the issue with the line-height not being used.  The line height was being set to a class object.  Then that class object was being called on a TD tag with a nested table inside it.  I moved the class object to be part of the TABLE tag and viola it started working.  onscroll still doesn't work with XHTML, but now it appears I don't have to use it.  Man I wish I could though...
0
 
LVL 3

Expert Comment

by:hemebond
Comment Utility
Why on Earth are you using XHTML? Transitional gives you no benefit over HTML. And you say you have nested tables? So you're not even using clean semantic code? You should learn how to use HTML correctly and cleanly before trying to use a stricter markup.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
The doctype I use is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

That keeps everything to the tightest standards short to XHTML. It is where I have found the least incompatibilities between IE and Mozilla, and I have never run into an issue with events. I don't use the XHTML doctype except experimentally, because the standard is still not mature, and I think there wil have to be some revisions before we see wide adoption.

Cd&
0
 
LVL 3

Author Comment

by:Kamoku-Wan
Comment Utility
Cobol,

Thanks for your help mate.  We aren't ready to migrate to Strict yet that is why we are using Transitional.  We are in the process.  I will have to do some testing with Strict to see if it blocks the onscroll event.

hemebond,

You are pretty cocky for not knowing the scope of the project.  Unfortunely, I don't have the time to discuss your knee-jerk reaction with you.  So I am going to award Cobol the points for attempting to help find a solution.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
Thanks for the A.

In defence of hemebond; they are right about the use of nested tables for layout management. That will create a lot of problems trying to maintain pages.  The modern approach is to seperate content from presentation using CSS to manage layout.  It is not always a quick and easy transition, but if you are migrating to a more flexible, standards-compliant presentation you will find the tables get in your way and each fix makes it more difficult to do the next one.

Cd&
0
 
LVL 3

Expert Comment

by:hemebond
Comment Utility
"You are pretty cocky for not knowing the scope of the project." If you plan on supporting Internet Explorer at all, use HTML. Simple.

COBOLdinosaur do you serve your pages as application/xhtml+xml ?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
text/html

Cd&
0
 
LVL 3

Expert Comment

by:hemebond
Comment Utility
Then what's the point of using XHTML markup?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
>>> Then what's the point of using XHTML markup?

Gee, maybe its because it costs nothing and at some point xhtml becomes the best choice.

I make a living by deliverying solutions that work the day I deliver them and every day after; and there is no profit in going back to fix mistakes you made because you were not capable of seeing three inches past today.

Cd&
0
 
LVL 3

Expert Comment

by:hemebond
Comment Utility
Oh well, with that attitude you must know better than me. And the W3c. And respected members of the web-developer community. I mean, you must have read http://www.hixie.ch/advocacy/xhtml and http://www.w3.org/MarkUp/2004/xhtml-faq.

And maybe you know some trick, that I don't, about stopping standards-compliant browsers from converting <br/> into <br>/. Or some way to make browsers render your code, without having to use error-correction to make <script/> into <script></script>.

I mean, you MUST know all about using global find+replace methods for updating clean, semantic markup.

Please, COBOLdinosaur, enlighten us.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
Why don't you post a list of mainstream browsers you THINK are standards compliant.  Then you can post the list of W3C standards that have actually been fully implemented by any major manufacturer. A developers job is to deliver product.  If you don't like a pragmatic approach to the use of the available tools, I suggest you start to work building the perfect toolset that will insure everything can be done to the standards that you think should be applied.

While you are at it you can add some information to your profile so we know if you are a 13-year old or just an academic whose only purpose in life is to lament the emphasis on getting thing to work instead of producing perfect abstractions.

If you want a debate then take it to the lounge or experts input, because if I post again in this thread it will be with an admin comment.

Cd&
0
 
LVL 3

Expert Comment

by:hemebond
Comment Utility
"While you are at it you can add some information to your profile so we know if you are a 13-year old or just an academic whose only purpose in life is to lament the emphasis on getting thing to work instead of producing perfect abstractions." Done. And currently I'm working in the construction industry where I use a web-based system to track Quality Assurance for my department.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now