Ho scoperto che Firefox ha un piccolo problemino con la gestione del wordwrap in una textarea: utilizzando wrap=”hard” , al post della textare il testo scritto o incollato che sia viene rivisitato forzatamente da firefox rendendolo illegibile oltre a sballare completamente la formattazione inserita dall’utente.

Esempio:

Prima del post:
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Dopo il post: 
Lorem Ipsum is simply dummy
text of the printing and typesetting industry.
Lorem Ipsum has been the industry’s
standard dummy text ever since the
1500s, when an unknown
printer took a galley of type
and scrambled it to make a type
specimen book. It has survived not
only five centuries, but also the leap
into electronic typesetting,
remaining essentially unchanged.
It was popularised in the 1960s with
the release of ecc ecc…

Non è ben chiaro questo comportamento, cioè del perchè Firefox decide arbitrariamente di mandare a capo ogni 2-3 parole il testo inserito.

Per risolvere il problema però è necessario usare wrap=”soft” e non ci sarà nessuna formattazione arbitraria.

Anche se il div da mostrare ha uno z-index di 100 e l’oggetto flash non ha z-index o è inferiore, suFireFox il div viene mostrato sotto l’oggetto flash stesso. Su IE7 e IE6 funziona senza nessun workaround.

Per ovviare velocemente al problema, nel tag <embed> dell’oggetto flash inserire l’attributo wmode=”transparent” . Il div andrà sopra all’oggetto flash in modo corretto. Questo workaround è applicabile su FireFox e Netscape e Safari, ma purtroppo su Opera non funziona.

Googlando però ho trovato questo esempio: Ok, è assurda come soluzione ma a quanto pare all’autore del post funziona.

Firefox (<= 2.0.0.7), parsando la risposta XML di una richiesta con XMLHttpRequest, tronca il textNode a 4096k.

E’ un dato di fatto e ne ho le prove (bestemmie e sangue amaro fino alle 8 di sera un giorno in ufficio). Non so perchè ma è così, e sembra che il comportamento sia condiviso anche da Opera (9.23, la versione che ho attualmente e su cui l’ho riscontrato). Il problema su IE6 e IE7 non si presenta.

Quindi cosa ne fa Firefox degli altri bytes rimanenti del textNode? Alloca N childNodes.

Esiste una soluzione a questo problema, cioè normalizzare l’oggetto XML creato con la responseXML con il metodo normalize()

  1.  
  2. function func()
  3. {
  4.         var xmlhttp = new XMLHttpRequest();
  5.         xmlhttp.open(‘GET’, url, true);
  6.         xmlhttp.onreadystangechange = function()
  7.         {
  8.                 if (xmlhttp.readyState == 4)
  9.                 {
  10.                         if (xmlhttp.status == 200)
  11.                         {
  12.                                 var doc = xmlhttp.responseXML;
  13.                                 var html = ;
  14.                                 if (doc.evaluate())
  15.                                 {
  16.                                         doc.normalize();
  17.                                         html = doc.getElementsByTagName(’string’)[0].childNodes[0].nodeValue;
  18.                                 }
  19.                                 else
  20.                                         html = doc.text;  
  21.  
  22.                                 return html;
  23.                         }
  24.                 }
  25.         }
  26. }

tip: la funziona evaluate()  è utile per capire se si è sotto Firefox\Opera o Internet Explorer e differenziare il metodo di interrogazione dell’XML (perchè ovviamente non sono uguali :) )