RE: DOCTYPE, javascript and Firefox

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

-----Original Message-----
From: tedd [mailto:tedd.sperling@xxxxxxxxx] 
Sent: 30 October 2008 03:58 PM
To: arno@xxxxxxxxxxxxxx; 'PHP - General'
Cc: Arno Kuhl
Subject: Re:  DOCTYPE, javascript and Firefox

At 3:45 PM +0200 10/30/08, Arno Kuhl wrote:
>I came across an odd thing with DOCTYPE, javascript and Firefox 3 that 
>has me stumped. Not exactly a php issue but hoping someone else on the 
>list has seen this before. (At least the script is php, hope that 
>counts)
>
>I have the following code in my header script:
>
>echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
>\"http://www.w3.org/TR/html4/loose.dtd\";>\n";
>
>
>Elsewhere I have (simplified):
>
>echo "<input type='radio' name='autostart' value='0'"
>         ."onclick=\"autostartlabel.className='disable';"
>         ."article.startdate.disabled=true;\" />No"
>     ."<input type='radio' name='autostart' value='1'"
>         ."onclick=\"autostartlabel.className='normal';"
>         ."article.startdate.disabled=false;\" />"Yes"; ...
>echo "<label id='autostartlabel'>Startdate"
>     ."<input type='text' name='startdate' id='startdate' disabled=true />"
>     ."</label>";
>
>
>It's simply 2 radio buttons and if "yes" is clicked related form fields 
>are enabled, if "no" is clicked they're disabled.
>
>This code works fine in IE, Opera and Chrome, but gives a javascript 
>error in FF when I click the radio button: "autostartlabel is not defined".
>However if I comment out the DOCTYPE line in the header it works fine 
>in all browsers including FF. (Took ages to narrow it down to the 
>DOCTYPE.) Does anyone know why, and how to fix it?
>
>Cheers
>Arno

Arno:

Wild guess, place this --

<?php header('Content-Type: text/css; charset=UTF-8'); ?>

-- before the DOCTYPE

HTH's,

tedd

--
-------

Hi tedd

Thanks for the suggestion. What it did though was output the html as text
rather than render the html. At least it's consistent across all browsers...
I tried changing it to "Content-Type: text/html;" which rendered the html
but still gave a js error in FF.

Cheers
Arno


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux