我试图进行重定向并传递#参数
// I'm at: http://example.com/index.html
var url = 'http://example.com/category.html';
var hash = '#testsite';
// Ignores # and all after
window.location.href = url + hash;
// Does not work, sets hash first, then redirects to url without maintaining hash
window.location.href = url;
window.location.hash = hash;
是否可以使用javasript重定向?
答案 0 :(得分:1)
不确定templocation
是什么,但效果很好:
var url = 'http://example.com/category.html';
var hash = '#testsite';
window.location.href = url + hash;
答案 1 :(得分:0)
也许你可以尝试类似下面的内容
var url = 'http://example.com/category.html';
var hash = '#testsite';
window.open(url+"?hash="+hash,"_self");
//http://example.com/category.html?hash=#testsite