这是我在PHP脚本中创建的部分表。
Date Description Month
Sun 3 - 14th Sunday of the year - July
Mon 4 - Week 14 of the year - July
or Saint Elizabeth of Portugal
Tue 5 - Week 14 of the year - July
or Saint Antony Mary Zaccaria, Priest
Wed 6 - Week 14 of the year - July
or Saint Maria Goretti, Virgin, Martyr
Thu 7 -
Fri 8 -
Sat 9 - Week 14 of the year - July
or Saint Augustine Zhao Rong and
his Companions, Martyrs
Sun 10 - 15th Sunday of the year - July
Mon 11 - Saint Benedict, Abbot - July
Tue 12 - Week 15 of the year - July
Wed 13 - Week 15 of the year, Saint Henry - July
Thu 14 - Week 15 of the year - July
or Saint Camillus of Lellis, Priest
Fri 15 - Saint Bonaventure, Bishop, Doctor - July
HTML将如下所示。
<div class="scrollBoxYe">
<table class="grid">
<tr><td>
<div name="20110703" class="lcday">
<div class="lcright">Sun 3</div>
<div class="lcmid"> - 14th Sunday of the year</div>
<div class="lcright">- July</div>
</div>
</td></tr>
.
.
.
.
</table>
</div>
class =“lcday”的div的名称将是一个锚标记。我希望能够将scrollBoxYe div滚动到与当天匹配的行。名称锚应该在div中还是在tr元素中?
onload事件对div元素有用吗?我希望能够在没有任何点击事件的情况下自动滚动div。如果onload事件不可用,那么自动加载div的最佳方法是什么。我更喜欢避免使用页面主体onload执行此操作,因为在同一页面上加载了不同的视图。
一旦我找到了自动加载div的正确事件,我想调用类似这样的函数。
function scrolltoanchor(row){
document.getElementById("scrollBoxYe").scrollTop = document.getElementById(row).offsetTop
}
函数参数是锚名称。
最重要的问题是: