Good day to you! There is a problem, here is the 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript" src="./system/scc.js"></script> <script type="text/javascript" src="system/connect/config/js/moveWin.js"></script> <script type="text/javascript"> function getAttributes(node) { var ret = new Object(); if(node.attributes) for(var i=0; i<node.attributes.length; i++) { var attr = node.attributes[i]; ret[attr.name] = attr.value; } return ret; } // function loadXML(xml) { var divlib = document.getElementById('xd'); var divid = document.getElementById('ldh'); divlib.innerHTML = xml; var c1 = divlib.getElementsByTagName('wins'); var c2 = c1.item(0).getElementsByTagName('win'); for (var i=0;i<c2.length;i++) { var elex = document.createElement('div'); var atr = getAttributes(c2.item(i)); elex.id = atr.id; elex.style.left = atr.left; elex.style.top = atr.top; elex.addEventListener('mousedown', function () { }, false); elex.className = 'moveDiv'; elex.innerHTML = 'xdd'+i; document.body.appendChild(elex); } } </script> <style type="text/css"> .moveDiv { position: absolute; background-color: #CCC; border-top-width: 10px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #000; border-right-color: #000; border-bottom-color: #000; border-left-color: #000; height: 300px; width: 100px; } </style> </head> <body> <div id="xd" style="display:none;"></div> <div id="ldh"></div><br /> <input type="button" onclick="presetLoader('./x.xml');" value="load" /> </body> </html> 

When this line is activated, alert (document.getElementById (this.id)); (click on a layer) the alert reports the following: object HTMLUnknownElement , this is solved like this:
elex.id = atr.id + 'abcdef'; Ie by adding a letter / letters to the end, but this is not convenient for me, and I need it without these letters.
The data is obtained from the xml file, code:

 <?xml version="1.0" encoding="utf-8"?> <wins counts="2"> <win id="win_allWidgets" left="200px" top="40px"></win> <win id="win_chat" left="100px" top="100px"></win> </wins> 

For loading the function is responsible:

 var toTpath; function presetLoader(toTpath) { use4connect = getXmlHttp(); use4connect.onreadystatechange = function() { if (use4connect.readyState == 4) { if (use4connect.status == 200){ sth = ''; } else { if (use4connect.status != 200){ return(false); } else { return(false); } } if(use4connect.status == 200) { loadXML(use4connect.responseText); } } } use4connect.open('GET', toTpath, true); use4connect.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); use4connect.send(null); } 

Prompt the correct code, or how to convert the values ​​obtained from xml into the "correct" line.

    1 answer 1

    Problem solved. The thing was that the xml document was written to the contents of the layer, and it contained elements with similar identifiers; after creating new layers, the layer that contained xml data was cleared and everything fell into place.