Also document.getElementById("mover_con").appendChild(food); hatte ich als erstes auch, hat aber nicht funktioniert. mover_con ist weiterhin null.
Bei mir geht der Link, wahrscheinlich waren die server down...
Und ich versuch mal des bild per js einzubinden.
Beiträge von Vollkornbrot
-
-
Hab mal wieder bisschen gecodet, aber das ist ein fehler drin^^
Soll so ne Art Snake werden. Is nich sonderlich schön gecodet, wolltes einfach mal zum laufen bringen:
place_food funzt nicht, Firefox meint mover_con wär null.JavaScript
Alles anzeigen<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="de"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <style type="text/css"> * { border:0px; margin:0px; padding:0px; } #mover { position:absolute; height:20px; width:20px; } #mover_con { height:400px; width:400px; background-image: url(background.png); } </style> <script type="text/javascript"> left = true; top = true; bottom = true; right = true; document.onkeydown = key_press; function rand (min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function init (){ mover = document.getElementById("mover"); mover.style.left = "100px"; mover.style.top = "40px"; } function key_press(events) { if(!events){ events = window.event; } if(events.which){ key(events.which); } else if(events.keyCode){ key(events.keyCode); } } function key(code) { if(code==37 && left){ move("left"); } if(code==38 && top){ move("top"); } if(code==39 && right){ move("right"); } if(code==40 && bottom){ move("bottom"); } } function move(where) { mover = document.getElementById("mover"); if(where == "left"){ mover_left = mover.style.left; dummy = mover_left.split("px"); left = dummy[0]-10; if(left>= "0"){ mover.style.left = left+"px"; } else { mover.style.left = mover.style.left; } } if(where == "right"){ mover_left = mover.style.left; dummy = mover_left.split("px"); dummy[0] = parseInt(dummy[0]); left = (dummy[0]+10); if(left<= "380"){ mover.style.left = left+"px"; } else { mover.style.left = mover.style.left; } } if(where == "top"){ mover_top = mover.style.top; dummy = mover_top.split("px"); top = dummy[0]-10; if(top>= "0"){ mover.style.top = top+"px"; } else { mover.style.top = mover.style.top; } } if(where == "bottom"){ mover_top = mover.style.top; dummy = mover_top.split("px"); dummy[0] = parseInt(dummy[0]); top = (dummy[0]+10); if(top<= "380"){ mover.style.top = top+"px"; } else { mover.style.top = mover.style.top; } } } function place_food(){ food = document.createElement("img"); food.src = "mover.png"; food.style.position = "absolute"; top = rand(0, 400)+"px"; left = rand(0, 400)+"px"; food.style.top = top; food.style.left = left; mover_con = document.getElementById("mover_con"); mover_con.appendChild(food); } place_food(); </script> </head> <body onload="init()"> <div id="mover_con"> <img src="mover.png" id="mover" /> </div> </body> </html>
Achja, hier zum ausprobieren. xD
-
Darf man fieldset außerhalb von form verwenden?
-
Ja
http://de.selfhtml.org/html/kopfdaten/meta.htm
Unter Automatisch weiterleitung -
Ja sind Variablen.
Also es scheint erst nicht mehr weiterzugehen wenn ich innerHTML verwende. Wenn die Schleife weg is läufts auch nich weiter. Ich versuch mal ohne innerHTML...
-
Ja, die Fehlerkonsole kenn ich, nur die zeigt keine Fehler beim Skript an^^
Aber da muss ja irgenwas falsch sein...E:
Grad kam doch nen Mitteilung:
"Invalid Chrome Url "
Früher gabs die nich^^
Was heißt das bzw was is ne Chrome Url?E2:
Jetzt kommt sie nich mehr^^
Kam nach jedem reload. Hatte aber glaub ich nix mit dem Skript zutun.
Laut Google hat das was mit den Firefox Addons zu tun... -
Liegt nicht nich an dem. Habs mal ausgebessert und statt nodeValue auch mal data versucht , hilft aber auch nix.
Schade, dass es nich nen JS Validator gibt -
Also nen <= bringt auch nix. Ich würd sagen die Schleife läuft nicht durch. Müsste dann eigentlich am "content += "<p>"+xml.getElementsByTagName("msg")[ i ].firstChildNode.value+"</p>";" liegen, aber was is da falsch?
:P
-
Hab mal den kompletten Javascript teil in den ersten post editiert. Vieleicht liegt ja da der Fehler.
Und
content = content+"<p>"+xml.getElementsByTagName("msg")[ i ].firstChild.nodeValue+"</p>";
und
content += "<p>"+xml.getElementsByTagName("msg")[ i ].firstChildNode.value+"</p>";
sind ja eigentlich äquivalent , kann also nich daran liegen.Hab die For-Schleife mal durch ne While ersetzt. In der schleife wird ein alert aber nur einmal ausgegeben obwohl die schleife eigentlich 2 Durchgänge hat.
msg_length ist auf jeden Fall 2.MfG
-
thx
hilft aber auch nix bzw. content = content+"<p>"+xml.getElementsByTagName("msg").firstChild.nodeValue+"</p>"; gibts ja gar nicht, nur mit nem[ i ]
Und firstChild.nodeValue oder firstChildNode.value macht doch keinen Unterschied oder?
Hab mal oben den JS Source "akutualisiert".
Das alert im source oben wird nich ausgegeben.@FatalErrors:
Was soll eine Leerzeile bringen bzw. was is der Fehler? -
Moin,
Also JS-Code:
JavaScriptfunction WholemealShout(shoutbox_content_id, shoutbox_input_form_id, shoutbox_bmsg_id){ var content_div = document.getElementById(shoutbox_content_id); var input_form = document.getElementById(shoutbox_input_form_id); var bot_span = document.getElementById(shoutbox_bmsg_id); var req = null; this.autorefresh = null; this.getXmlHttpRequest = function(){ if (window.XMLHttpRequest) { httpReq = new XMLHttpRequest(); } else if (typeof ActiveXObject != "undefined") { httpReq = ActiveXObject("Microsoft.XMLHTTP"); } return httpReq; } this.show = function(all){ all = all || 0; req = this.getXmlHttpRequest(); req.onreadystatechange = this.response_chat_xml; if(all==0){ req.open("GET", "WholemealShout.php?all=0", true); } else if(all == 1){ req.open("GET", "WholemealShout.php?all=1", true); } req.send(null); return null; } this.response_chat_xml = function(){ if(req.readyState == 4){ xml = req.responseXML; msg_length = xml.getElementsByTagName("msg").length; content = ""; i = 0; while(i<msg_length){ content += "<p>"+xml.getElementsByTagName("msg")[i].firstChild.data+"</p>"; i++; } content_div.innerHTML += content; if(xml.getElementsByTagName("aref") != null){ button = "<input type=\"button\" onclick=\"show()\" name=\"chat_act\" id=\"chat_act\" value=\"Aktualisieren\">"; input_form.innerHTML += button; } if(xml.getElementsByTagName("bmsg") != null){ bot = xml.getElementsByTagName("bmsg").firstChild.data; bot_span.innerHTML += bot; } req = null; } if(this.autorefresh == true){ setInterval(this.show, 300); } return null; } } var WholemealShout = new WholemealShout("shoutbox_content", "shoutbox_input_form", "shoutbox_bmsg"); WholemealShout.show(1);
und zurückgebebene XML-Datei:
XML<wholemealshout> <msg>BOT(18:46): Willkormmen! </msg> <msg>adsa(01:00): Moin</msg> </wholemealshout>
Angezeigt wird nachtürlich nix und wenn man nach der for-schleife ein alert setzt wird das auch nicht ausgeben...
thx
-
thx
Das andere hat sich erledigt^^.
-
Was ist mit "Du bist ein Besucher...?" gemeint?
-
Wie kann man in JS Default Parameter an Funktionen übergeben?
Oder geht das gar nicht^^? -
Öhm die datei ist 7.6mb groß und installiert sind das dann um die 16 Mb...
-
Oder du könntest auf einem Bild z.B An und Abmelden unterbringen^^
-
Das einzige jetzt bekannte was bei PHP im oo Bereich dazukommt sind namespace.
Sonst kommt noch Unicode unterstützung und kleinere Änderungen. -
Und Ajax ist Javascript + XML lolI know.
Aber wenn ich die Nachricht als: "Bla(12:02): Test" send sind das ja weniger Zeichen als:
<messages><message>Bla(12:02): Test</message></messages>.Lohnt sich das dann als unformatierter Text zu senden.(Wegem Traffic)
MfG
-
Moin,
PHP<?php global $shoutbox_wrap_style = "margin:0 auto; height:500px; width:200px; border:1px solid black;"; ?>
Ausgabe:ZitatParse error: syntax error, unexpected '=', expecting ',' or ';' in /usr/export/.../ on line 2
E:
Noch ne Frage:
Sollte man bei nem Ajax Chat die Daten in Xml senden? Müssen ja wieder mehr Zeichen übertragen werden oder ist das so wenig das es unwichtig ist? -
Ich nich ^^
Mach mal screen pls