Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

appendChild - Problem

Empfohlene Antworten

Veröffentlicht

Hi, ich möchte auf meiner seite ein neues div-Element einfügen, aber in der Zeile mit appendChild meckert mein debugger immer:"Ungültiges Argument"


   ...

   addNode: function (parent, id, text, href, target, info) {      

      var layer = document.createElement("div");

      var text = document.createElement("div");

      var link = document.createElement("a");

      var img = document.createElement("img");


      layer.style.top = "1px";

      layer.style.left = "1px";

      layer.style.position = "absolute";

      layer.style.visibility = "visible";

      layer.style.width = this.width;

      layer.style.height = this.height;

      layer.style.zIndex = 990;

      layer.setAttribute("onmouseover", "top.document.frames['navi'].DropDownNavi.over('"+id+"');");

      layer.setAttribute("onmouseout", "top.document.frames['navi'].DropDownNavi.out();");

      layer.setAttribute("class", "dropdown_element");

      layer.setAttribute("id", id);

      top.document.getElementById("navi_div").appendChild(layer);

      debug.getHTMLCode(top);

  },

  ...

  • das ganze ist teil einer klasse, darf leider nicht den gesammten quellcode reinstellen, aber die variablen id, this.height etc. habe ich schon mit alert ausgegeben, die sind richtig befüllt...
  • das element navi_div ist vorhanden und ich kann mit top.document.getElementById("navi_div") auch daruf zugreifen...
  • debug.getHTMLCode(top) ist eine funktion, die mir den html-code zur laufzeit als text in einem popup anzeigt (schon oft verwendet, nie probleme mit gehabt)

Verwendter Browser: ie6

navi_div ist vorhanden und in dem zustand in dem es sein sollte... :confused:

Meine Test.html schaut so aus und funktioniert:

<html>

<head>

<title>Test</title>

</head>


<body>


<script>

function addNewTest()

{

	/*var pTxt = document.createElement('p');

	pTxt.Value = 'Test';

	document.getElementById('test').appendChild(pTxt);*/

	document.getElementById('test').innerHTML += '<div>Test</div>';

}

</script>


<form name="formTest" action="">

<input type="button" value="Add" onclick="addNewTest()">

</form>


<div id="test"></div>


</body>

</html>
Das kannst Du mal probieren, denn die Methode appendChild() kenn ich nicht. Du musst das nur noch auf Deine Funktionalität abstrahieren. Also Layer nicht mit createElement, sondern mit
top.document.getElementById("navi_div").innerHTML += '<div id="meineID"></div>';

...getElementById('meineID').styles = ...

hmm schade das es mit appendChild nicht geht, naja innerHTML tuts zur not auch...

Verwendter Browser: ie6

hast du mal einen browser getestet?

möglicherweise mag er es nicht weils leer ist?

hab kein IE6 mehr, IE8 macht was er soll FF3.5 auch

@Vanatic: appendChild gehört zu DOM, ja das heißt nicht das IE6 das kennt, im gegenteil das macht es eher unwahrscheinlich.

Bearbeitet von _n4p_

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.