node表示没有哈希的res.redirect

时间:2014-02-28 00:55:57

标签: node.js express

页面网址为http://example.com/dashboard#/catalog。当cookie过期时,我会做一个

res.redirect('/login')

浏览器中生成的网址为http://example.com/login#/catalog

如何在没有散列部分的情况下重定向,即将网址设为http://example.com/login

感谢您的帮助!!

1 个答案:

答案 0 :(得分:0)

我不知道您是如何进行注销的,但假设您使用了链接标记,则可以执行此类操作

$("a#logout").on('click', function() {
  // the following was taken from http://stackoverflow.com/questions/4508574/remove-hash-from-url
  var loc = window.location.href,
      index = loc.indexOf('#');
  if (index > 0) {
     window.location = loc.substring(0, index);
  }
});