【问题标题】:Hashlink is not working in SafariHashlink 在 Safari 中不起作用
【发布时间】:2013-07-24 19:34:41
【问题描述】:

虽然使用 haslink (#testhash) 在 Safari 上不起作用。我真的无法找到问题所在。 这是我在下面提供的以下代码

<a href="?page_id=112#testhash">Click here to go to Hash</a>

<div style="height:500px">&nbsp;</div>
<div id="testhash"></div>
<div>............Test Data............</div>

当我单击该链接时,它会在 Safari 上正常运行,但在 Google Chrome、Mozila Firefox 和 IE9 上运行良好。在 Safari 中,链接在 URL 重写后重定向到站点 http://example.com/ 而不是 http://example.com/#testhash。有趣的是,当我直接将链接 http://example.com/#testhash 放在 Safari 的地址栏上时,它工作正常,但单击它的时间不起作用,而且当我写 http://example.com/?page_id=112#testhash 时,它会出现问题。

【问题讨论】:

  • This answer 可能会有所帮助。
  • 不,它也没有帮助。

标签: html wordpress browser safari


【解决方案1】:

您能否将 href 更改为“#testhash”,看看是否能解决您的问题?

编辑我的答案,因为它不清楚:

试试这个:

<a href="#testhash">Click here to go to Hash</a>

<div style="height:1200px">&nbsp;</div>
<a name="testhash" />
<div id="testhash"></div>

【讨论】:

  • 我已经更改了它并给了一个不同的名称作为#soumyahash。但还是一样
  • 编辑了我的答案你能看看这是否对你有帮助吗?
【解决方案2】:

你可以做一件事。给出完整链接而不是 ?page_id,因为有时 Safari 或其他一些浏览器会为 Wordpress 编写不同的重写规则,这就是 Hashlinks 不起作用的原因。你可以放

&lt;a href="http://testwordpress.com/[*rewritten Page By Browser]/#testhash"&gt;Click here to go to Hash&lt;/a&gt; 代替 &lt;a href="?page_id=112#testhash"&gt;Click here to go to Hash&lt;/a&gt; 它可能会起作用。

*我的意思是重写页面,因为浏览器将页面划分为父母和孩子,如about-us/page/etc,所以网址应该来自我的示例http://testwordpress.com/about-us/page/etc/#testhash

【讨论】:

    猜你喜欢
    • 2019-01-08
    • 2019-07-12
    • 2013-08-17
    • 2015-05-12
    • 2012-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多