473,781 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Firefox: correct xhtml DOCTYPE tag breaks script?

Hi folks,

I have created an animated image gallery in dhtml. It works fine in
Internet Explorer. In Firefox, it only works if I ommit the DOCTYPE tag.
The page is valid xhtml-strict but with a xhtml1-strict DOCTYPE, I get a
dead script and dozens of error messages like "Error in parsing value in
property 'width'. Declaration dropped." on Line 0.

This page doesn't work in Firefox but is valid xhtml:
http://schorpioen.demon.nl/test/gallery.html

This page works in Firefox but has no document type so doesn't validate:
http://schorpioen.demon.nl/test/gallery_no_doctype.html

What's happening?

Thanks for any insights,

Lennart
Aug 2 '06 #1
15 5406
Lennart wrote:
I have created an animated image gallery in dhtml. It works fine in
Internet Explorer. In Firefox, it only works if I ommit the DOCTYPE tag.
The page is valid xhtml-strict but with a xhtml1-strict DOCTYPE, I get a
dead script and dozens of error messages like "Error in parsing value in
property 'width'. Declaration dropped." on Line 0.
A number of browsers look at the Doctype and use it to judge how smart you
are. If they think you are smart they are less forgiving when it comes to
errors in CSS.
This page doesn't work in Firefox but is valid xhtml:
http://schorpioen.demon.nl/test/gallery.html
p.style.width=p arseInt(p.style .width)+parseIn t(p.style.width )*zoomfactor*p. prefix;

So you are assigning to the width property "An integer, multiplied by an
interger, multiplied by the zoom factor, multiplied by either 1 or -1"

.... but in CSS non-zero lengths require units.

width: 50; is not acceptable.

--
David Dorward <http://blog.dorward.me .uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Aug 2 '06 #2
On 02/08/2006 22:38, Lennart wrote:
I have created an animated image gallery in dhtml. It works fine in
Internet Explorer. In Firefox, it only works if I ommit the DOCTYPE tag.
The page is valid xhtml-strict but with a xhtml1-strict DOCTYPE, I get a
dead script and dozens of error messages like "Error in parsing value in
property 'width'. Declaration dropped." on Line 0.
Your CSS declarations are invalid; you're omitting units, which are
always required for non-zero length values.
This page doesn't work in Firefox but is valid xhtml:
http://schorpioen.demon.nl/test/gallery.html
You're also calling parseInt without specifying an explicit radix, which
isn't typically a good idea. My examination didn't stretch much further
than that.

[snip]

Mike
Aug 2 '06 #3

Lennart wrote:
I have created an animated image gallery in dhtml. It works fine in
Internet Explorer. In Firefox, it only works if I ommit the DOCTYPE tag.
The page is valid xhtml-strict but with a xhtml1-strict DOCTYPE, I get a
dead script and dozens of error messages like "Error in parsing value in
property 'width'. Declaration dropped." on Line 0.

This page doesn't work in Firefox but is valid xhtml:
http://schorpioen.demon.nl/test/gallery.html

This page works in Firefox but has no document type so doesn't validate:
http://schorpioen.demon.nl/test/gallery_no_doctype.html
The recent Mozilla family browsers become much more strict when you use
either xhtml 1.0 strict or html 4.01 strict. I find that the dhtml on
your page will not work either when the page is converted to html 4.01
strict. By the way, your page will work as written on Opera. If you
convert your page to html 4.01 transitional, Mozilla family browsers
become more loose and the html on your page will then validate at W3C
and work on recent versions of IE6, Opera, Firefox, Netscape, and
Mozilla. See http://www.cwdjr.info/dhtml/dhtmlPost.html .

So the easy way out is to just use html 4.01 transitional. I have seen
this same response by recent Mozilla family browsers many times for
older dhtml pages. In several cases, I have found that math is being
used to calculate some screen positions in pixels. If the numerical
result for the desired x or y position is not rounded using
Math.round(), a fractional pixel position may be calculated. IE6 and
Opera often do not mind this. However a fractional pixel position often
can completely kill the dhtml effect on recent Mozilla family browsers.
So, if you insist on code in strict html or strict xhtml, then first
start by carefully examining if any of the several calculations used in
your script can result in fractional pixel screen positions, and use
Math.round() or whatever else it may take to get rid of the fractions.
Of course the problem could be something else. Many things can kill a
dhtml script.

Aug 3 '06 #4

cwdjrxyz wrote:
[...]
So, if you insist on code in strict html or strict xhtml, then first
start by carefully examining if any of the several calculations used in
your script can result in fractional pixel screen positions, and use
Math.round() or whatever else it may take to get rid of the fractions
As a hint, one trick is to truncate the decimal part using bitwise OR:

var z = (x/y) | 0;

e.g. to get an integer random number in the range 0 to 4:

Math.random()*4 | 0;
It's often used where a function is called repeatedly at very short
intervals. It's much faster and less processor intensive than
repeatedly calling Math.round(), but of course truncation may not suit
the OP and the speed advantage may be irrelevant.

--
Rob

Aug 3 '06 #5
cwdjrxyz wrote:
<snip>
The recent Mozilla family browsers become much more strict
when you use either xhtml 1.0 strict or html 4.01 strict.
I find that the dhtml on your page will not work either when
the page is converted to html 4.01 strict. By the way, your
page will work as written on Opera. If you convert your page
to html 4.01 transitional, Mozilla family browsers become
more loose and the html on your page will then validate at
W3C and work on recent versions of IE6, Opera, Firefox,
Netscape, and Mozilla.
See http://www.cwdjr.info/dhtml/dhtmlPost.html .
<snip>

This is false. The distinction between (x)HTML strict and transitional
is not a factor in whether the browser renders in 'quirks' or
'standards' mode. If the page uses a formally correct (x)HTML
transitional DOCTYPE (as defined in the pertinent W3C specification)
then the browser in question will render in 'standards' mode and the
script will not work due to the absence of unit declarations in the
assigned CSS values.

Richard.
Aug 3 '06 #6
RobG wrote:
cwdjrxyz wrote:
[...]
>So, if you insist on code in strict html or strict xhtml,
then first start by carefully examining if any of the several
calculations used in your script can result in fractional
pixel screen positions, and use Math.round() or whatever
else it may take to get rid of the fractions

As a hint, one trick is to truncate the decimal part using
bitwise OR:

var z = (x/y) | 0;
<snip>
It's often used where a function is called repeatedly at
very short intervals. ...
<snip>

True, but CSS pixel units are not required to be integers so the
implication that the use of non-integers will influence the outcome on
Firefox is bogus.

Richard.
Aug 3 '06 #7
On Wed, 02 Aug 2006 23:29:47 +0100, David Dorward wrote:
>
p.style.width=p arseInt(p.style .width)+parseIn t(p.style.width )*zoomfactor*p. prefix;

So you are assigning to the width property "An integer, multiplied by an
interger, multiplied by the zoom factor, multiplied by either 1 or -1"

... but in CSS non-zero lengths require units.

width: 50; is not acceptable.


Ok, but I also need to read out the width and height of pictures, f.e.
with:

w = p.style.width;

And I assume that I get an integer back, not a string like "200px" or
anything else I can't really do calculations with. In fact with the xhtml
doctype in place, p.style.width is always *empty*, how do I solve that??

Aug 3 '06 #8
On 03/08/2006 13:01, Lennart wrote:
On Wed, 02 Aug 2006 23:29:47 +0100, David Dorward wrote:
[snip]
>... but in CSS non-zero lengths require units.

width: 50; is not acceptable.

Ok, but I also need to read out the width and height of pictures, f.e.
with:

w = p.style.width;
The style object represents in-line style sheet declarations; either
those assigned via scripting using the style object itself, or those
included in a style attribute.
And I assume that I get an integer back, not a string like "200px" or
anything else I can't really do calculations with.
Your assumption is wrong. The return value should be a string and, with
the exception of a zero length value (and not necessarily then), it
should include a unit.

The parseInt function will ignore trailing characters that aren't part
of the set of digits for the specified radix. That is,

parseInt("200px ", 10)

will return the number 200 as 'p' isn't a base-10 digit.
In fact with the xhtml doctype in place,
Serving XHTML as HTML is questionable anyway, but the issues are not
restricted to XHTML.
p.style.width is always *empty*, how do I solve that??
See above.

One alternative is to compute the value. However, that would limit
support as only a few browsers implement the getComputedStyl e method
(properly; Konqueror has false support), and be awkward as IE uses a
different (and inferior) mechanism.

Mike
Aug 3 '06 #9

Richard Cornford wrote:
RobG wrote:
cwdjrxyz wrote:
[...]
So, if you insist on code in strict html or strict xhtml,
then first start by carefully examining if any of the several
calculations used in your script can result in fractional
pixel screen positions, and use Math.round() or whatever
else it may take to get rid of the fractions
As a hint, one trick is to truncate the decimal part using
bitwise OR:

var z = (x/y) | 0;
<snip>
It's often used where a function is called repeatedly at
very short intervals. ...
<snip>

True, but CSS pixel units are not required to be integers so the
implication that the use of non-integers will influence the outcome on
Firefox is bogus.
I have seen many cases where older dhtml scripts fail on recent Mozilla
family browsers, including Firefox, when fractional pixel positions are
calculated and html 4.01 strict is used. Making sure that intergers are
used instead corrected the problem when there were not additional
problems on the page.. It may be true that CSS pixel units may not be
required to be integrals in some official specifications. However
recent Mozilla family browsers do not seem to know this in some cases
when you use html 4.01 strict, for example. Yet it does not seem to
matter if you convert the page to html 4.01 transitional. Pages with
such problems have been written by several authors. Have you actually
tested this on working pages? If not, using the term "bogus" is not
justified, in my opinion.

Aug 3 '06 #10

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

Similar topics

15
5855
by: Johan | last post by:
Hi, I've been working on the following piece of code and it works fine in IE and Opera, dut keep getting the same error in Firefox. Can anyone tell me what's wrong with this code? What I'm trying to do is rewrite the left (navigationframe) and load a page on the right (mainframe). tia, Johan
6
9563
by: NoCopy na | last post by:
Using the following example: domiframetest.html <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>DOM Iframe Test</title>
14
2327
by: expertware | last post by:
Ok! to avoid confusion I will start a new argument. Thanks!! FIREFOX 1.0.7 AND IE6 viewed through DATATIME: a summary REPORT =============================================================== by Pamela Datatime Team -----------------
6
2267
by: cjl | last post by:
I have a website which allows people to view interesting radiology cases. It is for teaching radiology residents. It is designed to run in fullscreen or 'kiosk' mode, at 1024 x 768 resolution only. http://www.casespace.net I designed it with firefox (plus the autohide extension) in mind, but also want to support IE. Online and offline it works great in Firefox. Offline it also works
23
2031
by: ivan | last post by:
AJAX is a stupid and confusing word. People is wondering for something that programmers have used for many years. Javascript + Xml and asynchronous requests is not new. People started to speak about AJAX a lot after XmlHttpRequest was introduced, so AJAX cant'be Javasript+xml+xmlhttprequest. But if you still think so, you can't anyway call this AJAX. What is new with xmlhttprequest is the possibility to perform a synchronous request! (but...
2
5702
by: André Wagner | last post by:
I'm trying to get all the "divs" that have a given NAME using getElementsByName(). For example, the following code: <html> <head> <script type="text/javascript"> function on_load() { var pages = document.getElementsByName("name");
9
1997
by: =?Utf-8?B?Sm9obiBCYWlsZXk=?= | last post by:
I have a ASP .Net page that allows moving around items on the page through javascript. This page works fine in IE. In FireFox however, I have found that if the page is using XHTML 1.0 Transitional as the doctype, you cannot set the style.left and style.top properties of image or div tags. If you remove the doctype from the page it works just fine, although I would rather not do this. You can work around this by setting the cssText...
3
9678
by: Tarik Monem | last post by:
Here is the html code <?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>test xml import</title> <script type="text/javascript">
3
3243
by: Arielle | last post by:
Problem: Using an XHTML doctype for all our pages, this is not optional. The layout the client wants to use requires the site to be "full screen" with a header, footer, horizontal menu, and main content area. The header may or may not be absolute, the menu and footer are absolute, and the main content is dynamic to fill the rest of the space. The idea is to use javascript to make up where css lacks forcing things to a full height. This...
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10143
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.