473,408 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Javascript fails to work with xhtml 1.0 strict DTD

Hello everyone,

I am attempting to create a xhtml page that uses a bit of dhtml.
The javascript I am using uses
document.getElementById('someId').style.someProper ty; and is and
external script. My page uses this dtd:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

It validates at the wc3 validator as correct xhtml, but the problem is
my script does not function. When I remove the dtd, the script
functions as normal.

I am obviously missing something here and would appreciate any
feedback.

Paul Marsh.
Jul 23 '05 #1
7 2004
Paul Marsh wrote:
Hello everyone,

I am attempting to create a xhtml page that uses a bit of dhtml.
The javascript I am using uses
document.getElementById('someId').style.someProper ty; and is and
external script. My page uses this dtd:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

It validates at the wc3 validator as correct xhtml, but the problem is
my script does not function. When I remove the dtd, the script
functions as normal.

I am obviously missing something here and would appreciate any
feedback.

Paul Marsh.


Link pls.
Jul 23 '05 #2


Paul Marsh wrote:

I am attempting to create a xhtml page that uses a bit of dhtml.
The javascript I am using uses
document.getElementById('someId').style.someProper ty; and is and
external script. My page uses this dtd:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

It validates at the wc3 validator as correct xhtml, but the problem is
my script does not function. When I remove the dtd, the script
functions as normal.

I am obviously missing something here and would appreciate any
feedback.


What exactly are you trying to do? Which browser fails? An error
messages or warning given by the browser?
If you include such a DOCTYPE declaration browsers like Mozilla or
Netscape 6/7 switch to standard compliants mode and therefore ignore
things like
element.style.left = 200
as that is not correct CSS, a unit is missing so you need
element.style.left = '200px';
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3
Paul Marsh wrote:
I am attempting to create a xhtml page that uses a bit
of dhtml.
A strange thing to do given how few scriptable dynamic browsers
understand XHTML.
The javascript I am using uses
document.getElementById('someId').style.someProper ty;
and is and external script. My page uses this dtd:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

It validates at the wc3 validator as correct xhtml, but the
problem is my script does not function. When I remove the dtd,
the script functions as normal.
So you don't care to mention what "function as normal" constitutes, or
how "does not function" differs?
I am obviously missing something here
Yes; code, context and explanation. Indeed this is a case for a URL to
the page (or a cut down page demonstrating the problem alone) because it
isn't even certain that you are creating an XHTML document, rather than
a malformed HTML document that syntactically resembles XHTML, and there
for it isn't possible to tell if it is an HTML DOM or an XHTML DOM that
you are actually scripting.
and would appreciate any feedback.


Without any pertinent information to go on any answer is ginning to be a
guess. And given that there are probably an infinite number of ways of
creating erroneous and fragile scripts a guess is such a long shot that
it is hardly worth writing, and definitely doesn't warrant any
explanation:-

The formal doctype is putting the browser into 'CSS1Compat' mode and the
assignments of non-zero values to dimensions-type style properties do
not include the required units declaration.

Richard.
Jul 23 '05 #4
Hi Richard,

yes in hindsight of course I should have included some additional
info... it was my first post and I'll be sure to
be more careful next time.

As for this: "A strange thing to do given how few scriptable dynamic
browsers understand XHTML."

That's a fairly negitive tone, I'm here 'cause I don't know all the
answers.

You complain that it's not certain my document is xhtml, but I mentioned
in my post that it validates at the wc3 validator as correct xhtml.

Anyway, it works now that I have declared the units so thanks, but you
should probably get out more.

Paul.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #5
Hi Martin,

yes, now that I have declared the units it works. I'll be sure to
include more detailed information in future posts.
Thanks for your reply, I'd better go do some more reading!

Paul.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #6
Paul Marsh wrote:
Hi Richard,
yes in hindsight of course I should have included some
additional info... it was my first post and I'll be
sure to be more careful next time.

As for this: "A strange thing to do given how few scriptable
dynamic browsers understand XHTML."

That's a fairly negitive tone, I'm here 'cause I don't
know all the answers.
Words of warning have a tendency to be negative.
You complain that it's not certain my document is xhtml, but I
mentioned in my post that it validates at the wc3 validator as
correct xhtml.
That is totally irrelevant to a web browser, if you send a content-type
header of text/html then the browser sees the document as (malformed)
HTML and builds an HTML DOM to be scripted. And if you send a correct
XHTML content-type header IE browsers cannot display the results, making
that a non-viable option in a commercial contexts. Which leaves
server-side content negotiation as the only way of using real XHTML and
accommodating IE, with the consequence that you will probably also need
to send a different script designed to work with each of the two types
of DOM (and that is a lot of extra effort in order to use XHTML, with
extremely questionable returns).
Anyway, it works now that I have declared the units so thanks,
but you should probably get out more.


Shoot yourself in the foot, why don't you? Welcome to the George Hester
filter.

Richard.
Jul 23 '05 #7
I have converted several old dhtml codes from the browser war era to
modern single path getElementById. It is very common to find problems
with codes from this era when you clean them up for a specific
Doctype. For example, after you strip layers and document.all support
from one of the fireworks scripts at DynamicDrive and clean it up to
4.01 transitional standards, all is fine on several modern browsers.
However if you just change to html 4.01 strict with the DOCTYPE
required for it, the script fails completely on some browsers. The
problem in such cases usually can be traced down to the CSS. I have
seen units such as px used for top and left, but not for width and
height. For moving things, I have seen such as blah.left=40 or
blah.left=x instead of the now required blah.left=40px or
blah.left=x+'px' . The faulty codes often will work on the IE6
browser, but not on Opera and the Mozilla family - Big
Mozilla(Mozilla), Baby Mozilla(FireFox), and Fat Mozilla(Netscape). So
the place I start when I have this sort of problem is to check
everything in the script and html that has anythig to do with CSS and
ask myself if the expression needs a unit in addition to a number.
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sergio del Amo Caballero | last post by:
Hello, I want to validate my simple page with xhtml 1.0 strict. But i want to use javasript inside. When i try the validator the answer is: Error: # Line 33, column 39: there is no attribute...
6
by: Jonny | last post by:
How can you validate Javascript generated HTML for XHTML 1.0 strict compliance? To avoid the "<" and "&" problem, all inline scripts MUST be enclosed with either: <!-- script --> Looked down...
3
by: Robert Smith | last post by:
I have a very basic form validation script, which wont work due to XHTML Strict not allowing me to use the name attribute on a form. Here is part of my code: if...
11
by: Dag Sunde | last post by:
We have this web-app that requires Javascript to be enabled in the UA (this is okay'ed by our customer). Now I want to make a "pre" page before the login screen, informing the user that he/she...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
4
by: cedwa | last post by:
I am developing a site at http://www.nwlmi.org.uk The problem lies with the CSS/XHTML Menu which relies on JavaScript to open and close the sections. The parent sections open and close fine but...
1
by: mmalloc | last post by:
I have the following code to move some text with javascript that works both on ie and ff. I can't make it XHTML compatble. If i remove the doctype info it will work. I'm sorry to bother with such...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.