'Bookmarklet redirecturl trims off #tag

I have a bookmarklet I use to autologin to certain test sites but I have it to where I can redirect them to specific pages after the login occurs. However the urls I try to redirect to contain #pageName, and it ends up trimming it off and just redirecting to the base page. How can I edit and rewrite it to work properly?

function (redirecturl) 
{ 
  var redirecturl =   encodeURIComponent(redirecturl || window.location.href); 
  window.location = window.location.origin + "/account/login/admin?redirecturl="+redirecturl;
})
  (window.location.href + encodeURIComponent("dashboard/spa#leads"));


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source