Есть страничка на ней надо вывесть таблицу которая при навидении курсора выделяет строку(используя JavaScript).
Проблема:
при отрытии demo.php всё ОК, но когда загружаю через div на форме загружается только статическая таблица(JavaScript не работает)
Как можно решить данную проблему :confused:
index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script src="demo.js" type="text/javascript" defer="defer"></script>
</head>
<body onLoad="loadResult()">
<div id="result"/>
</body>
</html>
demo.js
function updatePage() {
if (req.readyState == 4) {
if (req.status == 200) {
var response = req.responseText;
document.getElementById("result").innerHTML = response;
} else {
alert("status is " + req.status);
}
}
}
function loadResult() {
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = updatePage;
if (req.readyState > 1) req.abort();
req.open("POST", 'demo.php');
req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
req.setRequestHeader('Cache-Control', 'no-cache');
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send('');
} else if (window.ActiveXObject) {
req = new ActiveXObject("Msxml2.XMLHTTP");///("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = updatePage;
if (req.readyState > 1) req.abort();
req.open("POST", 'demo.php');
req.setRequestHeader('Cache-Control', 'no-cache');
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send('');
}
}
}
demo.php
<!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 profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="imagetoolbar" content="no" />
<script type="text/javascript">
var stripe = function() {
var tables = document.getElementsByTagName("table");
for(var x=0;x!=tables.length;x++){
var table = tables[x];
if (! table) { return; }
var tbodies = table.getElementsByTagName("tbody");
for (var h = 0; h < tbodies.length; h++) {
var even = true;
var trs = tbodies[h].getElementsByTagName("tr");
for (var i = 0; i < trs.length; i++) {
trs[i].onmouseover=function(){
this.className += " ruled"; return false
}
trs[i].onmouseout=function(){
this.className = this.className.replace("ruled", ""); return false
}
if(even)
trs[i].className += " even";
even = !even;
}
}
}
}
window.onload = stripe;
</script>
<style type="text/css" media="screen">
table{
border: 1px solid #666;
}
tr td{
font-family: "lucida grande", verdana, sans-serif;
font-size: 8pt;
padding: 3px 8px;
background: #fff;
}
thead td{
color: #fff;
background-color: #999999; /*C8C028;*/
font-weight: bold;
border-bottom: 1px solid #999;
}
tbody td{
border-left: 1px solid #D9D9D9;
}
tbody tr.even td{
background: #eee;
}
tbody tr.selected td{
background: #3d80df;
color: #ffffff;
/*font-weight: bold;*/
border-left: 1px solid #346DBE;
border-bottom: 1px solid #7DAAEA;
}
tbody tr.ruled td{
color: #000;
background-color: #C6E3FF;
/*font-weight: bold;*/
/*border-color: #3292FC;*/
}
/* Opera fix */
head:first-child+body tr.ruled td{
background-color: #C6E3FF;
}
</style>
</head>
<body>
<table cellspacing="0">
<thead>
<tr>
<td width="40%">Ф.И.О.</td>
<td width="30%">Должность/Отдел</td>
<td width="20%">E-Mail</td>
<td width="10%">Номер</td>
</tr>
</thead>
<tbody>
<tr>
<td>Ф.И.О.</td>
<td>Должность/Отдел</td>
<td>E-Mail</td>
<td>Номер</td>
</tr>
<tr>
<td>Ф.И.О.</td>
<td>Должность/Отдел</td>
<td>E-Mail</td>
<td>Номер</td>
</tr>
<tr>
<td>Ф.И.О.1111111111111111111111111</td>
<td>Должность/Отдел</td>
<td>E-Mail</td>
<td>Номер</td>
</tr>
</tbody>
</table>
</body>
</html>