Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Internet Explorer: whitespace problem

[es] :: Javascript i AJAX :: Internet Explorer: whitespace problem

[ Pregleda: 2117 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

bzero
dev null
europe

Član broj: 5907
Poruke: 371
*.dynamic.sbb.co.yu.

Jabber: bzero@elitesecurity.org
Sajt: www.google.com/search?q=b..


Profil

icon Internet Explorer: whitespace problem15.08.2006. u 15:25 - pre 215 meseci
Imam ovaj HTML:
Code:

<html>
<head>
<title>whitespace test</title>
<script type="text/javascript">
function gettext(item) {
    var textnode = item.firstChild;

    alert("text: " + textnode.data + "\nlength: " + textnode.data.length);
    alert("innerHTML: " + item.innerHTML + "\ninnerHTML length: " + item.innerHTML.length);
}
</script>
</head>
<body>
<div style="white-space: pre" onclick="gettext(this)">a   b</div>
</body>
</html>


Stvar je prosta, imam jedan div i treba da uzmem tekst koji se nalazi u njemu. Problem je sto ovo radi u Firefoxu i Operi, a naravno u Exploreru ne radi kako treba. Naime, text koji se nalazi u div-u je: a[space][space][space]b.
FF i Opera i za data textNoda i za innerHTML, korektno daju slova a i b sa tri spejsa izmedju, sto je ukupna duzina 5 karaktera, dok IE u oba slucaja vraca a i b sa jednim razmakom izmedju, odnosno string duzine 3 karaktera.
Jel imao neko slican problem?
Never trust an operating system you don't have sources for.
 
Odgovor na temu

bzero
dev null
europe

Član broj: 5907
Poruke: 371
*.dynamic.sbb.co.yu.

Jabber: bzero@elitesecurity.org
Sajt: www.google.com/search?q=b..


Profil

icon Re: Internet Explorer: whitespace problem15.08.2006. u 15:33 - pre 215 meseci
U medjuvremenu sam izgleda nasao resenje.
Ukoliko se pre ispisa u HTML spejsovi zamene sa &nbsp; item.firstChild.data ce da radi korektno u sva tri browsera.
Never trust an operating system you don't have sources for.
 
Odgovor na temu

Br@nkoR
http://localhost

Član broj: 2597
Poruke: 1603

Sajt: localhost


+23 Profil

icon Re: Internet Explorer: whitespace problem15.08.2006. u 15:52 - pre 215 meseci
Ili dodaj DOCTYPE
Code:
<!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>
<title>whitespace test</title>
<script type="text/javascript">
function gettext(item) {
    var textnode = item.firstChild;

    alert("text: " + textnode.data + "\nlength: " + textnode.data.length);
    alert("innerHTML: " + item.innerHTML + "\ninnerHTML length: " + item.innerHTML.length);
}
</script>
</head>
<body>
<div style="white-space: pre" onclick="gettext(this)">a   b</div>
</body>
</html>

Banned - Not available
 
Odgovor na temu

bzero
dev null
europe

Član broj: 5907
Poruke: 371
*.dynamic.sbb.co.yu.

Jabber: bzero@elitesecurity.org
Sajt: www.google.com/search?q=b..


Profil

icon Re: Internet Explorer: whitespace problem15.08.2006. u 16:14 - pre 215 meseci
Citat:
Br@nkoR: Ili dodaj DOCTYPE


Tnx, radi i tako.
Never trust an operating system you don't have sources for.
 
Odgovor na temu

[es] :: Javascript i AJAX :: Internet Explorer: whitespace problem

[ Pregleda: 2117 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.