【问题标题】:Changing pages with a single link but keeping the hash part使用单个链接更改页面但保留哈希部分
【发布时间】:2014-08-12 00:08:36
【问题描述】:

有2个页面,1个是ENG.html另外1个是GER.html.,这2个页面中有一些标签,它们的链接是:eng.html#workeng.html#abouteng.html#home

当点击更改语言链接时,无论我身在何处,我都需要留在#work 或#home,该怎么做?请不要发布 php、html 和 javascript,其他都可以接受,我不想创建 2 个单独的 (ENG, GER) 文件夹,有什么建议吗?

【问题讨论】:

  • 有什么建议?表现出一些努力怎么样。
  • @putvande 回答一个非常非常简单的问题有那么痛苦吗?
  • @Bluefire SO 的想法是帮助解决现有程序中出现的问题,而不是作为免费的编码服务。问题简单与否应该没有区别。
  • 确实如此。但是,我认为任何建议 都不能保证像 putvande 这样的回应。您没有必须展示已完成的任何工作,如果您这样做了,我们将不胜感激。

标签: javascript jquery html url hyperlink


【解决方案1】:

试试这个:

// set the url we're going to
var url = "GER.html", // for example
// get the hashtag text
hash = window.location.hash,    
// make the new url
loc = url + hash;
// finally, go there
window.location.href = loc;

【讨论】:

    猜你喜欢
    • 2012-03-28
    • 2011-02-19
    • 1970-01-01
    • 2011-07-23
    • 1970-01-01
    • 2017-11-18
    • 2014-10-02
    • 1970-01-01
    相关资源
    最近更新 更多