Hallo,
ich habe folgende index.html:
SO sieht die: functions.js aus:
und die php datei die aufgerufen wird:
Und zwar habe ich in der php Datei eine funktion openDirectory() die nicht ausgeführt wird... Angezeigt im quelltext wird die funktion wenn ich ->View Generated Source anklicke, aber ausgeführt wird diese funktion nicht... Ich möchte gerne wissen, warum nicht und wie man das ändern kann, dass diese ausgeführt wird.
ich habe folgende index.html:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>New Document</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<script src="functions.js" type="text/javascript"></script>
</head>
<body onload="openDirectory('./', 'directory');">
<div id="directory"></div>
</body>
</html>
Code:
var xmlHttp = false;
//XMLHttpRequest-Instanz erstellen
//... für Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
xmlHttp = false;
}
}
//... für Mozilla, Opera, Safari usw.
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function openDirectory(dir, path)
{
if (xmlHttp) {
xmlHttp.open('GET', 'directory.php?dir='+dir, true);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
document.getElementById(path).innerHTML = xmlHttp.responseText;
}
};
xmlHttp.send(null);
}
}
function klapp(id)
{
if (document.getElementById(id).style.display === 'none')
{
document.getElementById(id).style.display = 'block';
}
else
{
document.getElementById(id).style.display = 'none';
}
}
PHP-Code:
<?php
$path = $_GET['dir'];
$handle = opendir($path);
$i = 0;
while ($data = readdir($handle))
{
if ($data !== '.' && $data !== '..')
{
if (is_dir($data))
{
echo '<div style="border:1px solid #000000;" onClick="klapp(\''.$data.'\')">'.$data.'
<div id="'.$data.'" style="display:none;">
<script language="javascript" type="text/javascript">openDirectory('pfad', 'pfad');</script>s</div></div>';
}
else
{
echo '<div style="border:1px solid #000000;">' . $image . ' ' . $data . '</div>';
}
}
$i++;
}
?>
EDIT:
zeilenumbrüche sponsored by kropff
Kommentar