可能,这将解决您的问题(来源):
$('#result').load('ajax/test.html #container');
当这个方法执行时,它会检索 ajax/test.html 的内容,然后 jQuery 会解析返回的文档以找到 ID 为 container 的元素。该元素及其内容被插入到 ID 为 result 的元素中,其余检索到的文档将被丢弃。
假设您只有“a.html”并且您的 div 的 id 是“divId”,您需要放置在您的 refresh() 函数中:
$('#divId').load('a.html #divId');
编辑
然后代码应该是(在 div 中放置 javascript 函数并更改“刷新”函数):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
body {
background-image: url('../Images/Black-BackGround.gif');
background-repeat: repeat;
}
body td {
font-Family: Arial;
font-size: 12px;
}
#Nav a {
position:relative;
display:block;
text-decoration: none;
color:black;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
setInterval( function refresh()
{
$('#toptable').load('0355.htm #toptable');
}, 1500);
</script>
</head>
<body>
<div id="toptable" align="center">
<SCRIPT type="text/javascript" src="../Images/jsdate.js"></script>
<SCRIPT type="text/javascript">function Jump(s){ window.location.href = s ;}</SCRIPT>
<script type="text/javascript">
//====================================================================================================================
// Date Difference
//====================================================================================================================
function GetDiff (dt) {
sMins = " Min";
sHours = " Hrs";
sDays = " Days";
sSecs = " Secs";
if ( Math.abs (DateDiff ("s", now, dt)) < 86400 ) {
if ( Math.abs (DateDiff ("s", now, dt)) <= 3600 ) {
return ((Math.floor(Math.abs (DateDiff ("s", now, dt)/60)*100)/100).toFixed(2) + sMins);
}
else
{
return ((Math.floor(Math.abs (DateDiff ("s", now, dt)/3600)*100)/100).toFixed(2) + sHours);
}
}
else
{
return ((Math.floor(Math.abs (DateDiff ("s", now, dt)/86400)*100)/100).toFixed(2) + sDays);
}
}
//====================================================================================================================
// Function Draw Row
//====================================================================================================================
</script>
<script type="text/javascript">
function DrawRow ( link,Status,Value,ResultName,DateTime,LSL,OPT,USL,LCL,UCL,LO1L,UO1L,LO2L,UO2L,CpK,CP,PPK,PP,TestDue,TestLate,ExpNeeded,ExpLate,AddsNeeded,AddsLate,Count,ActiveCount,Dummy1,ReviewedBy,TestID,ItemID,Dummy2,Test1,Test2,Test3,Test4,Test5,T1,T2,S ) {
s = "#008A00";
now = new Date();
//====================================================================================================================
// Color Coding For Results
//====================================================================================================================
if ( (Number (Status) & 1073741824) > 0 ) {
s = "#C0C0C0";
a = "center";
h = "22";
cr = "#000000";
sz = "2";
}
else
{
a = "left";
h = "22";
sz = "1";
cr = "#000000";
if ( DateDiff ("n", DateTime, "01/01/1980 00:00") == 0 ) {
Value = "Not-Tested";
DateTime = "Not Tested";
ResultName = ResultName + " - Needs To Be Tested";
}
}
if (( Number(Status) & 4) > 0 ) { s = "#0000FF"; cr = "#FFFFFF"; }
if (( Number(Status) & 32) > 0 ) { s = "#52CC29"; cr = "#000000"; }
if (( Number(Status) & 16) > 0 ) { s = "#FF4D94"; cr = "#000000"; }
if (( Number(Status) & 2) > 0 ) { s = "#FFFF00"; cr = "#000000"; }
if (( Number(Status) & 1) > 0 ) { s = "#E80000"; cr = "#FFFF00"; }
if (( Number(Status) & 8) > 0 ) { s = "#FF6600"; cr = "#000000"; }
if (( Number(Status) & 0) > 0 ) { s = "008A00"; cr = "#000000"; }
//====================================================================================================================
// Test Status Timing
//====================================================================================================================
ReviewIcon = "<p align='center' width='20' height='21'><font size='1'> </font>";
Dummy2 = "<b><p align='center' width='20' height='21'><font size='1'> </font></b>";
if ( Number(ActiveCount) != -1 ) {
sz = "1";
a = "left";
h = "22";
if ( TestDue > "" && TestLate > "" ) {
duedif = DateDiff ("s", TestDue, now);
if ( DateDiff ("s", TestDue, now) >= 0.0 ) { ReviewIcon = "<img src='../Images/Green-Test.png' width='20' height='21'>"; Dummy2 ="<strong><font size='"+sz+"' color = "+cr+">Due In " + GetDiff (TestLate);}
else
{
duedif = Math.abs (duedif);
if ( duedif < 3600 ) { duestg = String(Number(Math.floor((duedif/60)*100)/100).toFixed(2)) + " Min"; }
if (( duedif < 86400 ) && ( duedif >= 3600 )) { duestg = String(Number(Math.floor((duedif/3600)*100)/100).toFixed(2)) + " Hrs"; }
if ( duedif >= 86400 ) { duestg = String(Number(Math.floor((duedif/86400)*100)/100).toFixed(2)) + " Days"; }
Dummy2= "<p align='center' width='20' height='22'><b><font size='1' color = "+cr+">Start In " + duestg + "</font></b>";
ReviewIcon="<img src='../Images/Blue-Test.png' width='20' height='21'>";
}
}
if ( TestLate > "" ) {
if ( DateDiff ("s", TestLate, now) >= 0 ) { ReviewIcon = "<img src='../Images/Red-Test.png' width='20' height='21'>"; Dummy2 = "<strong><font size='1' color = "+cr+">Late By " + GetDiff (TestLate);}
}
if ( TestDue <="" ) {ReviewIcon="<img src='../Images/Not-Scheduled.png' width='20' height='21'>"; Dummy2 = "<b><font size='"+sz+"' color = "+cr+">Not Scheduled";
}
if ( Number(ActiveCount) < Number(Count) ) {ReviewIcon= "<img src='../Images/GrayAstris.png' width='20' height='21'>"; Dummy12 = "<strong><font size='"+sz+"' color = "+cr+">Deactivated";
}
}
//====================================================================================================================
// Date-Time Format
//====================================================================================================================
fmtDateTime = DateTime;
if ( IsDate(DateTime) ) {
mnth = DatePart ("m", DateTime);
dy = DatePart ("d", DateTime);
yr = DatePart ("yyyy", DateTime); // full four-digit year
yr2 = DatePart ("yyyy", DateTime)-2000; //should provide last two-digits of year
hrs = DatePart ("h", DateTime);
mn = DatePart ("n", DateTime);
sc = DatePart ("ss", DateTime);
if ( mnth.toString().length == 1 ) { mnth = "0" + mnth; }
if ( dy.toString().length == 1 ) { dy = "0" + dy; }
if ( mn.toString().length == 1 ) { mn = "0" + mn; }
ampm = "am";
//bug#604
if ( Number(hrs) >= 12 ) {
ampm = "pm";
if (Number(hrs) >= 13) {
hrs = String(Number(hrs) - 12);
}
}
fmtDateTime = (String(mnth) + "/" + String(dy) + "/" + String(yr2) + " " + String(hrs) + ":" + String(mn) + " " + String(ampm));
}
//====================================================================================================================
// Draw Result Name
//====================================================================================================================
document.write( "<tr bgcolor='"+s+"' height='"+h+"' >" );
document.write( "<td bg color='#000000' width='2%' height='21' >"+ReviewIcon+"</td>" );
document.write( "<td "+link+" width='134' height='22'><p align='center'><b>"+Dummy2+"</b></font></td>" );
document.write( "<td "+link+" width='55'><p align='center'><b><font size='"+sz+"' color='"+cr+"'>"+Value+"</font></td>");
document.write( "<td "+link+" width='243'><p align='"+a+"'><strong><font size='"+sz+"' color='"+cr+"'> "+ResultName+" </strong></font></td>" );
document.write( "<td "+link+" width='100'><p align='center'><b><font size='"+sz+"' color='"+cr+"'>"+ fmtDateTime +"</strong></font></td>" );
document.write( "<td "+link+" width='52'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+LSL+" </font></td>" );
document.write( "<td "+link+" width='52'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+OPT+" </font></td>" );
document.write( "<td "+link+" width='52'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+USL+" </font></td>" );
document.write( "<td "+link+" width='54'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+LCL+" </font></td>" );
document.write( "<td "+link+" width='54'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+UCL+" </font></td>" );
document.write( "<td "+link+" width='56'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+CpK+" </font></td>" );
document.write( "</tr>" );
}
//====================================================================================================================
// Function Draw Add Row
//====================================================================================================================
function DrawAddRow ( link,Status,Action,Amount,Unit,Consumable,DueBy,TestReportID,Dummy1,SignedOff,TestID,ItemID,Dummy2,DateTme ) {
if ( SignedOff == 0 ) {
s = "#008A00";
cr = "#000000";
sz = "2";
if ( (Number(Status) & 1073741824) > 0 ){
s = "#C0C0C0";
a = "center";
h = "22";
cr = "#000000";
SignOffIcon = " ";
}
else
//====================================================================================================================
// Add Status
//====================================================================================================================
{
a = "left";
h = "18";
sz = "1";
if ( DueBy > "" ) {
if ( DateDiff("n", now, DueBy) >= 0 ) { s = "#008A00"; cr="#000000"; Dummy2 = "<b><font size='"+sz+"' color = "+cr+">Due In " + GetDiff (DueBy); Dummy1 = "<img src='../Images/Green-Test2.png' width='20' height='18'>";}
if ( DueBy > "" ) {
if ( DateDiff("n", DueBy, now) >= 0 ) { s = "#E80000"; cr="#FFFF00"; Dummy2 = "<b><font size='"+sz+"' color = "+cr+">Late By " + GetDiff (DueBy); Dummy1 = "<img src='../Images/Red-Test2.png' width='20' height='18'>";}
}
}
}
//====================================================================================================================
// Draw Add Row
//====================================================================================================================
document.write( "<tr bgcolor='"+s+"' height='"+h+"' >" );
document.write( "<td width='2%' ><p align='center'><B><font size='"+sz+"' color='"+cr+"'>"+Dummy1+"</td>" );
document.write( "<td width='16%' ><p align='center'><B><font size='"+sz+"' color='"+cr+"'>"+Dummy2+"</td>" );
document.write( "<td width=32%'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+Consumable+" </font></td>" );
document.write( "<td width='9%'><p align='center'><b><font size='"+sz+"' color='"+cr+"'>"+Action+"</font></td>");
document.write( "<td width='10%'><p align='center'><b><font size='"+sz+"' color='"+cr+"'>"+Amount+"</font></td>");
document.write( "<td width='7%'><p align='center'><b><font size='"+sz+"' color='"+cr+"'>"+Unit+"</font></td>" );
document.write( "<td width='13%'><p align='center'><b><font size='"+sz+"' color='"+cr+"'>"+DueBy+"</font></td>" );
document.write( "<td width='10%'><p align='center'><b><font size='"+sz+"' color='"+cr+"'>"+TestReportID+"</font></td>" );
document.write( "</tr>" );
}
}
function DrawRow2 ( link,Status,Value,ResultName,DateTime,LSL,OPT,USL,LCL,UCL,LO1L,UO1L,LO2L,UO2L,CpK,CP,PPK,PP,TestDue,TestLate,ExpNeeded,ExpLate,AddsNeeded,AddsLate,Count,ActiveCount,Dummy1,ReviewedBy,TestID,ItemID,Dummy2,Test1,Test2,Test3,Test4,Test5,T1,T2,S ) {
s = "#008A00";
now = new Date();
//====================================================================================================================
// Color Coding For Results
//====================================================================================================================
if ( (Number (Status) & 1073741824) > 0 ) {
s = "#C0C0C0";
a = "center";
h = "22";
cr = "#000000";
sz = "2";
}
else
{
a = "left";
h = "22";
sz = "1";
cr = "#000000";
if ( DateDiff ("n", DateTime, "01/01/1980 00:00") == 0 ) {
Value = "<img src='../Images/Not-Tested.png' width='53' height='23'>";
DateTime = "Not Tested";
ResultName = ResultName + " - Needs To Be Tested";
}
}
if (( Number(Status) & 2) > 0 ) { s = "#FFFF00"; cr = "#000000"; }
if (( Number(Status) & 1) > 0 ) { s = "#E80000"; cr = "#FFFF00"; TestIcon = "FFFF00" }
document.write( "<tr bgcolor='"+s+"' height='"+h+"' >" );
document.write( "<td "+link+" width='245'><p align='"+a+"'><b><font size='"+sz+"' color='"+cr+"'> "+ResultName+" </font></td>" );
document.write( "<td "+link+" width='50'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+L01L+" </font></td>" );
document.write( "<td "+link+" width='50'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+L01U+" </font></td>" );
document.write( "<td "+link+" width='50'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+PpK+" </font></td>" );
document.write( "<td "+link+" width='50'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+PpK+" </font></td>" );
document.write( "<td "+link+" width='52'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+Pp+" </font></td>" );
document.write( "<td "+link+" width='52'><p align='center'><b><font size='"+sz+"' color='"+cr+"'> "+Cp+" </font></td>" );
document.write( "</tr>" );
}
</script>
<table border="0" width="850" id="Nav" cellpadding="0" cellspacing="0" valign="top">
<tr>
<td stylE="float:none; height:60; width:850px; align:center;">
<TABLE style="float:left;border:5px; border-style:outset;border-color:#E80000; height:20px; width:23%; border-spacing:0; border-collapes:collapse;">
<TR Style="background-color:#595959;color:FFFF00;"> <TH Style="border:1px solid #FFFF00;font-size:12px; width:45;height:20;"><div style="text-align:center; margin-bottom:-1px;"> Symbol </TH> <TH Style="border:1px solid #FFFF00;font-size:12px; width:125;height:20;"><div style="text-align:center; margin-bottom:-1px;">Meaning</TH> </TR>
<TR> <TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Not-Scheduled.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Not Scheduled</TD></TR>
<TR> <TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Gray-Astris3.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;"> Deactivated Tanks </TD></TR>
<TR> <TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Blue-Test.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test Scheduled</TD></TR>
<TR> <TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Green-Test.png); background-size:22px 24px; width:22; height:24; background-repeat:no-repeat; background-position:center;"></TD> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test In Process</TD></TR>
<TR> <TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Red-Test.png); background-size:22px 24px; width:22; height:24; background-repeat:no-repeat; background-position:center;"></TD> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test Late</TD></TR>
</TABLE>
<div align="center">
<img style="float:none; margin-left:auto; margin-right:auto; margin-top:17px; border:10px ridge #E80000; width:199; height:101;"src="../Images/Logo.jpg" />
<TABLE style="float:right;border:5px; border-style:outset;border-color:#E80000; height:20px; width:23%; border-spacing:0; border-collapes:collapse;">
<TR Style="background-color:#595959;color:FFFF00;"> <TH Style="border:1px solid #FFFF00;font-size:12px; width:125;height:20;"><div style="text-align:center; margin-bottom:-1px;">Meaning</TH><TH Style="border:1px solid #FFFF00;font-size:12px; width:45;height:20;"><div style="text-align:center; margin-bottom:-1px;"> Symbol </TH></TR>
<TR> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Not Scheduled</TD><TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Not-Scheduled.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR>
<TR> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;"> Deactivated Tanks </TD><TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Gray-Astris3.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR>
<TR> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test Scheduled</TD><TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Blue-Test.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR>
<TR> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test In Process</TD><TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Green-Test.png); background-size:22px 24px; width:22; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR>
<TR> <TD style="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test Late</TD><TD style="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Red-Test.png); background-size:22px 24px; width:22; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR>
</td>
</tr>
</div>
<div id="description>
<table>
<tr>
<td style="height:5px; text-align:center;"></td></tr>
</table>
<table style="border-style:none; width:850px: height:73px; border-spacing:0; border-collapse:collapse; vertical-align:top; text-align:center;">
<tr>
<TD style="background-color:#000000;color:FFFF00; height:20px; text-align:center; font-face:arial; font-size:24px; font-weight:bold;">IEC's TrueLogic Dashboard</td>
</tr>
</div>
<div id="group">
<table>
<tr>
<td style="height:4px; text-align:center;"></td></tr>
</table>
<table style="border-style:none; width:850px: height:73px; border-spacing:0; border-collapse:collapse; vertical-align:top; text-align:center;">
<td style="height:20px; text-align:center;"></td>
<TD style="background-color:#000000;color:FFFF00; height:24px; text-align:center; font-face:arial; font-size:20px; font-weight:normal;">[GroupName]</td>
</div>
<div id="object">
<table>
<tr>
<td style="height:4px; text-align:center;"></td></tr>
</table>
<table style="border-style:none; width:850px; border-spacing:0; border-collapse:collapse; vertical-align:top;">
<td style="float:left;width:5;"><a href=[BackLink]><img border="0" src="../Images/Back-ButtonB.gif" width="80" height="18"></td>
<TD style="text-align:center; background-color:#000000;color:FFFF00; height:20px; font-face:arial; font-size:18px; font-weight:bold;">[ObjectName]</td>
<td style="width:26px;">
</table>
</div>
<div id="drawrow" align="center">
<table>
<tr><td style="height:8px;"></td></tr>
</table>
<TABLE style="float:center;border:5px; border-style:outset;border-color:#E80000; width:850px; height:18px; border-spacing:0; border-collapes:collapse;" table border="1">
<script type="text/javascript">
DrawRow ("","1073741824","<b>Value</B>","<b>Result Name</b>","<b>Date - Time</b>","<b>LSL</b>","<b>Opt.</b>","<b>USL</b>","<b>LCL</b>","<b>UCL</b>","<b>LO1L</b>","<b>UO1L</b>","<b>LO2L</b>","<b>UO2L</b>","<b>CpK</b>","Cp","<b>Ppk</b>","<b>PP</b>","<b>ItemID</b>","Dummy1","Dummy2","Dummy3","Dummy4","Dummy5",1,-1,"Dummy6",1,0,0,"Dummy7");
[ItemsHTML]</script>
</table>
<table>
<tr><td style="height:20px;"></td></tr>
</table>
<TABLE style="float:center;border:5px; border-style:outset;border-color:#E80000; width:850px; border-spacing:0; border-collapes:collapse;" table border="1">
<div id="addrow"><script type="text/javascript">
DrawAddRow ("","1073741824","Action","Amount","Units","Chemical Additive","Due By","Report ID","","","0","0","Due Status");
[AddItemsHTML]</script></div>
</table>
<table>
<tr><td style="height:20px;"></td></tr>
</table>
<table>
<tr><td style="height:10px;"></td></tr>
</table>
<table>
<tr><td style="height:5px;"></td></tr>
</table>
</div>
<div id="signoff" align="center">
<table style="border-style:none; width:850px; border-spacing:0; border-collapse:collapse; vertical-align:top;">
<td style="height:25px;">
<table style="border-style:none; width:850px; border-spacing:0; border-collapse:collapse;">
<tr>
<TD style="background-color:#000000;color:FFFF00;bwidth:335px; text-align:left; font-size:10;">By TrueLogic Company Edited By International Electronic Components</td>
<td width="290"></td>
<TD style="background-color:#000000;color:FFFF00; bwidth:135px; text-align:right; font-size:10;">[LastBuild]</td>
</tr>
</table>
<tr><td style="height:25px;"></td>
</td>
</div>
</tr>
</table>
</div>
</body>
</html>