0

IE では正常に動作しますが、FF では何もしません。

これが私が使用しているコードです。このコードは、proboards.com に対していくつかのことを行います。この場合、コードの説明は関係ないと思います。そうでない場合は、お知らせください。

しかし、焦点部分は単に単一の要素に焦点を当てることです。

コードは次のとおりです。

<script>
var TitleBarGuestMessage="Hello Guest!";
var TitleBarMemberMessage="Welcome Back "+pb_displayname+"!";
var i,table,LTPI,LTPItable,titlerow,titlerowcell1,LTPIrow,LTPIrowcell1,shortcutA,shortcutB,shortcutC,
td=document.getElementsByTagName("td");LTPItable= document.getElementById("rectangle_table");LTPI=document.getElementById("rectangle_right_side");LTPItable.style.width="100%";
shortcutA=LTPI.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
shortcutB=shortcutA.previousSibling.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;shortcutC=shortcutA.firstChild;
shortcutA.previousSibling.parentNode.parentNode.cellSpacing="0";
shortcutA.previousSibling.style.display="none";
shortcutB.className="";
shortcutB.bgColor="transparent";
shortcutC.align="center";
shortcutC.style.backgroundColor="transparent";
shortcutC.className="";
LTPI.style.display="none";
for(i=0;i<td.length;i++){
if(td[i].className=="titlebg" && td[i].colSpan=="2"){
td[i].parentNode.parentNode.parentNode.id="forum";}}
table=document.getElementById("forum");
if(pb_action=="home"){
setTimeout(function(){table.focus();}, 2000)};
titlerow=table.insertRow(0);
titlerowcell1=titlerow.insertCell(0);
titlerowcell1.className="titlebg";
titlerowcell1.colSpan="5";
titlerowcell1.id="LTPI_titlebar";
LTPIrow=table.insertRow(1);
LTPIrowcell1=LTPIrow.insertCell(0);
LTPIrowcell1.colSpan="5";
LTPIrowcell1.innerHTML=LTPI.innerHTML;
LTPIrowcell1.id="LTPI_row";
if(pb_username=="Guest"){
titlerowcell1.innerHTML=TitleBarGuestMessage}
else{titlerowcell1.innerHTML=TitleBarMemberMessage}
</script>

これは、スクリプトの焦点部分です。

if(pb_action=="home"){
    setTimeout(function(){table.focus();}, 2000)};

私も試しました:

setTimeout("table.focus();",2000);

助言がありますか?

4

1 に答える 1

0

これは、DOM テーブル要素にメソッドがないためfocusです (ただし、IE で実装されています)。その要素までスクロールする必要があると想定しているので、次のようにできます。

window.scrollTo(0,table.scrollHeight);

または、正確なコードのように:

if(pb_action=="home"){
    setTimeout(function(){window.scrollTo(0,table.scrollHeight)}, 2000)};
于 2012-08-24T23:51:23.113 に答える