Javascript js window.location不工作

Javascript js window.location不工作,javascript,dom,Javascript,Dom,我在标签中嵌入了链接列表,例如 <ul> <li><a href='/111'>Link1</a></li> <li><a href='/555'>Link1</a></li> <li><a href='/444'>Link1</a></li> <li><a href='/222'>Link1</a><

我在
  • 标签中嵌入了链接列表,例如

    <ul>
    <li><a href='/111'>Link1</a></li>
    <li><a href='/555'>Link1</a></li>
    <li><a href='/444'>Link1</a></li>
    <li><a href='/222'>Link1</a></li>
    <li><a href='/333'>Link1</a></li>
    </ul>
    

    TIA

    如何调用
    窗口。作为onclick事件处理程序导航到
    方法
    
    window.navigate_to = function(event, direction) {
        var current_location, next_url, node, prev_url, url;
        if (event.preventDefault) {
          event.preventDefault();
        } else if (event.stop) {
          event.stop();
        } else {
          "";
        }
        if (direction == null) {
          direction = 1;
        }
        current_location = window.location.pathname;
        console.log(current_location);
        node = document.querySelector("a[href*='" + current_location + "']");
        if (node != null) {
          next_url = node.parentNode.nextElementSibling != null ? node.parentNode.nextElementSibling.querySelector("a[href]").getAttribute('href') : "";
          prev_url = node.parentNode.previousElementSibling != null ? node.parentNode.previousElementSibling.querySelector("a[href]").getAttribute('href') : "";
          console.log(node);
          console.log(next_url, prev_url);
          url = direction === 1 ? next_url : prev_url;
          console.log(window);
          console.log(url);
          window.location = window.location.host + url;
          return true;
        }
    };