Javascript 在跟踪动态重建表中的链接后,如何返回到该表中的起始位置?
我从本地存储器重建一个表(tbody)。必要时,我重建Javascript 在跟踪动态重建表中的链接后,如何返回到该表中的起始位置?,javascript,rebuild,Javascript,Rebuild,我从本地存储器重建一个表(tbody)。必要时,我重建 单击表格下方的按钮,您可以在中看到表格的完整视图 向右移动到列标题“tLink”(所有其他标题都是“Foo”、“Bar”)。然后在列中向下移动,直到到达带有链接的单元格。点击它,你会在另一个页面上看到一个图像。从它返回时,包含链接的单元格上的位置丢失,变为0,0 // Build the table from the origin document <script type="text/javascript"> funct
单击表格下方的按钮,您可以在中看到表格的完整视图
向右移动到列标题“tLink”(所有其他标题都是“Foo”、“Bar”)。然后在列中向下移动,直到到达带有链接的单元格。点击它,你会在另一个页面上看到一个图像。从它返回时,包含链接的单元格上的位置丢失,变为0,0
// Build the table from the origin document
<script type="text/javascript">
function storeLocOeuvresTbl()
{
var oTable = document.getElementById('myOeuvresTable');
var s = "";
var stopAlert = true;
if (oTable == null) // TJC: Invalid ID, ignore it
{
alert("myOeuvresTable not found!");
return "";
}
var versIE = isIE();
var aTBODY = oTable.getElementsByTagName("tbody");
localStorage.setItem("myOeuvresTableTBlen", aTBODY.length);
// set the CSS class for each one of the TR tags
for (var i = 0; i < aTBODY.length; i++)
{
// get an array of all the TR tags in the TBODY
// TJC: It's actually a NodeList, but you can largely
// treat it as an array
var aTR = aTBODY[i].getElementsByTagName("tr");
localStorage.setItem("myOeuvresTableTB" + i + "len", aTR.length);
for (var j = 0; j < aTR.length; j++)
{
var aTD = aTR[j].getElementsByTagName("td");
localStorage.setItem("myOeuvresTableTB" + i + "TR" + j + "len", aTD.length);
var aTDlen = parseInt(localStorage.getItem("myOeuvresTableTB" + i + "TR" + j + "len"));
for (var k = 0; k < aTD.length; k++)
{
s = s + aTD[k].id + ": " + aTD[k].innerHTML + "|";
var tdId = "myOeuvresTableTB" + i + "TR" + j + "TD" + k;
var innerHTML = "";
if (aTD[k].innerHTML.length > 0)
{
innerHTML = aTD[k].innerHTML;
}
else
{
innerHTML = " ";
}
localStorage.setItem(tdId, innerHTML);
innerHTML = localStorage.getItem(tdId);
if (stopAlert == false && (versIE != false) && (versIE < 9))
{
alert("innerHTML get: " + innerHTML);
if (window.confirm("Stop Alert?"))
{
stopAlert = true;
}
}
}
s = s + "\n";
}
}
return s;
}
//从原始文档构建表
函数storeLocaoUVRestBL()
{
var-oTable=document.getElementById('myOeuvresTable');
var s=“”;
var stopAlert=true;
如果(oTable==null)//TJC:ID无效,则忽略它
{
警报(“未找到myOeuvresTable!”);
返回“”;
}
var versIE=isIE();
var aTBODY=oTable.getElementsByTagName(“tbody”);
localStorage.setItem(“myeouvrestabletblen”,aTBODY.length);
//为每个TR标记设置CSS类
对于(变量i=0;i0)
{
innerHTML=aTD[k].innerHTML;
}
其他的
{
innerHTML=“”;
}
setItem(tdId,innerHTML);
innerHTML=localStorage.getItem(tdId);
如果(stopAlert==false&&(versIE!=false)&&(versIE<9))
{
警报(“innerHTML获取:”+innerHTML);
如果(窗口确认(“停止警报”))
{
stopAlert=true;
}
}
}
s=s+“\n”;
}
}
返回s;
}
//重新生成目标文档的加载
函数getInventOeuvresTblFromStoreLoc()
{
var tbl=document.getElementById('myOeuvresTable');
var s=“”;
var tdId=“”;
var innerHTML=“”;
var aTBODYlen=0;
var aTRlen=0;
var-aTDlen=0;
var stopAlert=true;
var arrent=新数组(“onMouseOver”、“onMouseOut”、“onClick”、“onDbleClick”、“onMouseUp”、“onMouseDown”、“onFocus”、“onBlur”);
var DATE\u RE=/^(\d\d?[\/\.-](\d\d?[\/\.-](\d\d)?\d\d)$/;
如果(tbl==null)//TJC:ID无效,则忽略它
{
警报(“未找到myOeuvresTable!”);
返回“”;
}
var versIE=isIE();
aTBODYlen=parseInt(localStorage.getItem(“myOeuvresTableTBlen”);
//为每个TR标记设置CSS类
对于(变量i=0;i
嘿,欢迎来到StackOverflow。我只是想评论一下,如果你能把你的问题分解成我们所说的问题,那么在你的问题上得到帮助就容易多了。如果你能将你的问题再细分一点,并澄清你的实际问题,那么用户可以更容易地帮助你。请参阅附加信息(第二段)。文本编辑器拒绝保留这一小段代码Vuulez Suvre Ce Lou-Prand AgANDILLA表SUN UNE页SePaBeE.BR>。
// Rebuild onLoad of the destination document
<script type="text/javascript">
function getInventOeuvresTblFromStoreLoc()
{
var tbl = document.getElementById('myOeuvresTable');
var s = "";
var tdId = "";
var innerHTML = "";
var aTBODYlen = 0;
var aTRlen = 0;
var aTDlen = 0;
var stopAlert = true;
var arrEvent = new Array("onMouseOver", "onMouseOut", "onClick", "onDbleClick", "onMouseUp", "onMouseDown", "onFocus", "onBlur");
var DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
if (tbl == null) // TJC: Invalid ID, ignore it
{
alert("myOeuvresTable not found!");
return "";
}
var versIE = isIE();
aTBODYlen = parseInt(localStorage.getItem("myOeuvresTableTBlen"));
// set the CSS class for each one of the TR tags
for (var i = 0; i < aTBODYlen; i++)
{
// get an array of all the TR tags in the TBODY
// TJC: It's actually a NodeList, but you can largely
// treat it as an array
var tblBody = tbl.tBodies.item(i);
aTRlen = parseInt(localStorage.getItem("myOeuvresTableTB" + i + "len"));
for (var j = 0; j < aTRlen; j++)
{
var row = document.createElement("tr");
aTDlen = parseInt(localStorage.getItem("myOeuvresTableTB" + i + "TR" + j + "len"));
for (var k = 0; k < aTDlen; k++)
{
var cell = document.createElement("td");
tdId = "myOeuvresTableTB" + i + "TR" + j + "TD" + k;
innerHTML = localStorage.getItem(tdId);
if (innerHTML.substr(0, 7).toLowerCase() == "<a href")
{
var link = document.createElement("a");
var indDblQuote1 = innerHTML.indexOf('"');
var indDblQuote2 = innerHTML.indexOf('"', indDblQuote1 + 1);
var indOf1 = innerHTML.indexOf(">");
var indOf2 = innerHTML.toLowerCase().indexOf("</a>");
var cellLink = innerHTML.substring(indDblQuote1 + 1, indDblQuote2);
var cellText = innerHTML.substring(indOf1 + 1, indOf2);
if (stopAlert == false && (versIE != false) && (versIE < 9))
{
var s = "innetHTML: " + innerHTML + "; " + "cellLink: " + cellLink + "; " + "cellText: " + cellText;
alert(s);
if (window.confirm("Stop Alert?"))
{
stopAlert = true;
}
}
link.setAttribute('href', cellLink);
link.appendChild(document.createTextNode(cellText));
cell.appendChild(link);
}
else
{
var cellText = document.createTextNode(innerHTML);
cell.appendChild(cellText);
}
row.appendChild(cell);
s = s + tdId + ": " + innerHTML + "|";
}
tblBody.appendChild(row);
s = s + "\n";
}
tbl.appendChild(tblBody);
}
return s;
}
</script>