在一个HTML中有这样一段代码:<table width="100%" cellspacing="0" cellpadding="0" border="0" align="left" style="display: block;" id="tip_confirmPassword"><tbody><tr><td width="14" valign="top" align="left"/><td height="20" valign="middle" align="left" id="errorbox"> Please enter the confirmed password</td></tr></tbody></table>
var error = document.getElementById("errorbox");
我怎么通过error这个NODE, 得到tip_confirmPassword这个节点, 
并用window.location.href跳到这个节点上呢, 用抛锚的方式

解决方案 »

  1.   


    <script>
    window.onload=function(){
      var err = document.getElementById("errorbox"); 
      var tb = err.parentNode.parentNode.parentNode;
      tb.scrollIntoView();}
    </script>
    <br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <table width="100%" cellspacing="0" cellpadding="0" border="0" align="left" style="display: block;" id="tip_confirmPassword"> <tbody> <tr> <td width="14" valign="top" align="left"/> <td height="20" valign="middle" align="left" id="errorbox"> Please enter the confirmed password </td> </tr> </tbody> </table>