nntp2http.com
Posting
Suche
Optionen
Hilfe & Kontakt

document.getElementById("element").style.(left|top)

Von: Lorenz Gorse (gorse95@gmail.com) [Profil]
Datum: 15.06.2008 19:50
Message-ID: <48555677$0$6563$9b4e6d93@newsspool3.arcor-online.net>
Newsgroup: de.comp.lang.javascript
Hallo,
ich experimentiere gerade etwas mit DOM rum und bin beim style-Objekt
hängengeblieben.

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" xml:lang="de"
lang="de">

<head>

<title>Titel</title>

<script language="javascript" type="text/javascript">
var x;
var y;
function init()
{
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = pos;
}
function pos(e)
{
x = e.clientX;
y = e.clientY;
var variable = x+","+y;
document.getElementById('text').innerHTML = variable;
document.getElementById('text').style.left = x+"px";
document.getElementById('text').style.top = y+"px";
}
</script>


</head>

<body onload="init()">

<div id="text"></div>
</body>

</html>
Die Zuweisung von left und top klappt nicht. Mit anderen Eigenschaften,
wie zum Beispiel font-famiy klappt es. Ich benutze Firefox 3.

Viele Grüße,
Lorenz

[ Auf dieses Posting antworten ]

Antworten