我创建了一个 HTML 页面 (index.html)。我还在 script 文件夹/目录中创建了一个 (mechanism.js)。然后,我根据需要使用 form、table、span 和 div 标签将所有内容放在 (index.html) 中。现在,这是让后退/前进什么都不做的技巧!
首先,您只有一页!二、使用带有span/div标签的JavaScript,在需要时通过常规链接在同一页面上隐藏和显示内容!
在'index.html'内:
<td width="89px" align="right" valign="top" style="letter-spacing:1px;">
<small>
<b>
<a href="#" class="traff" onClick="DisplayInTrafficTable();">IN</a>
</b>
</small>
[ <span id="inCountSPN">0</span> ]
</td>
在“mechanism.js”内部:
function DisplayInTrafficTable()
{
var itmsCNT = 0;
var dsplyIn = "";
for (i=0; i<inTraffic.length; i++)
{
dsplyIn += "<tr><td width='11'></td><td align='right'>" + (++itmsCNT) + "</td><td width='11'></td><td><b>" + inTraffic[i] + "</b></td><td width='11'></td><td>" + entryTimeArray[i] + "</td><td width='11'></td><td>" + entryDateArray[i] + "</td><td width='11'></td></tr>";
}
document.getElementById('inOutSPN').innerHTML =
"" +
"<table border='0' style='background:#fff;'><tr><th colspan='21' style='background:#feb;padding:11px;'><h3 style='margin-bottom:-1px;'>INCOMING TRAFFIC REPORT</h3>" +
DateStamp() +
" - <small><a href='#' style='letter-spacing:1px;' onclick='OpenPrintableIn();'>PRINT</a></small></th></tr><tr style='background:#eee;'><td></td><td><b>###</b></td><td></td><td><b>ID #</b></td><td></td><td width='79'><b>TYPE</b></td><td></td><td><b>FIRST</b></td><td></td><td><b>LAST</b></td><td></td><td><b>PLATE #</b></td><td></td><td><b>COMPANY</b></td><td></td><td><b>TIME</b></td><td></td><td><b>DATE</b></td><td></td><td><b>IN / OUT</b></td><td></td></tr>" +
dsplyIn.toUpperCase() +
"</table>" +
"";
return document.getElementById('inOutSPN').innerHTML;
}
它看起来很复杂,但请注意函数名称和调用、嵌入的 HTML 和 span 标签 id 调用。这是为了展示如何将不同的 HTML 注入同一页面上的同一 span 标签中!后退/前进如何影响此设计?它不能,因为您在同一页面上隐藏对象并替换其他对象!
我们如何隐藏和显示?如下:
'mechanism.js'里面的函数根据需要使用:
document.getElementById('textOverPic').style.display = "none"; //hide
document.getElementById('textOverPic').style.display = ""; //display
'index.html'内部通过链接调用函数:
<img src="images/someimage.jpg" alt="" />
<span class="textOverPic" id="textOverPic"></span>
和
<a href="#" style="color:#119;font-size:11px;text-decoration:none;letter-spacing:1px;" onclick="HiddenTextsManager(1);">Introduction</a>