【问题标题】:Why does window.location.href not showing the hash in IE为什么 window.location.href 没有在 IE 中显示哈希
【发布时间】:2012-05-06 23:13:49
【问题描述】:
window.location.href = 'www.mysite.com/testpage/#12';

在 Chrome 和 Firefox 中,用户成功重定向到 www.mysite.com/testpage/#12,但是在 IE 中,用户在没有哈希的情况下被定向到 www.mysite.com/testpage/,我该如何强制浏览器读取哈希?

更新:

这是实际代码:

window.location.href = siteurl+'?selection/'+edu_year_selectionreal+'/'+semester_selectionreal+'/'+subject_selectionreal+'#?selection/'+edu_year_selectionreal+'/'+semester_selectionreal+'/'+subject_selectionreal+'/'+edu_year_selectiontitle+'/'+semester_selectiontitle+'/'+subject_selectiontitle;

在 IE 中,它从 (#?) 开始停止读取

【问题讨论】:

  • 在 IE6 中无法使用,在 IE7+ 中可以正常使用。
  • 我已经在 Windows 7 的 IE 9.0.8112.16421 中成功测试过。页面 (HTTP 3XX) 是否重定向了什么?
  • 我对问题进行了编辑,请阅读。
  • 基本上等于`location.href = 'stackoverflow.com/#Test';'。您是否确保您请求的页面不会重定向?
  • 不,它不会重定向,并且在 chrome 和 firefox 上运行良好,问题仅出在 IE 上

标签: javascript hash


【解决方案1】:

发现错误: siteurl+'?selection/ 应该是 siteurl+'/?selection/,在 URL 的两部分之间有一个额外的“/”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-01
    • 2011-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-12
    • 1970-01-01
    相关资源
    最近更新 更多