1
#!/bin/sh
echo "Content-type: text/html"
echo ""
echo '<html>'
echo '<head>'
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
echo '</head>'
echo '<body><center><br><h3 align='center'>STATUS</h3></br></center>'
list=$(ls -l /tmp | grep "^d" | awk -F" " '{print $9}')
list1=$(echo $list | wc -w)
i=1
while [ $i -le $list1 ]
do
bhai=$(echo $list | cut -d' ' -f$i)
echo '<a href="#" onclick="myFunction(); return false;" id="movie" style="font-size: 30px; text-decoration: none; margin-left: 1cm">'$bhai'</a></font><br>'
i=$((i+1))
done
echo '
<script type="text/javascript">
function myFunction() {
var mtype = document.getElementById("movie").text;
alert("Hi");
alert(mtype);
}
</script>'
echo '</body></html>'
exit 0
此代码基本上显示目录中的文件夹列表,并且由于href属性,所有目录都变为链接。如果我点击该链接,它应该打开该目录并显示所选目录的文件夹。
此代码显示唯一的第一个目录,如果我点击任何链接,警报只给我第一个目录的名称。
var mtype = document.getElementById("movie").text;
我是新来的,请帮助我。
在此先感谢
谢谢@jevgenig,你为我做了很多,也节省了我的时间。再次感谢。 –