dqkkrt8860 2019-07-31 10:58
浏览 60
已采纳

使用包含文件的锚点?

I try to use the anchor tag with the include I have. On my Index.php I got a little "nav bar" with some anchor tags. I also included the file "text.php" in my code. This file is in the Folder "texte". The anchor tags should bring the user to the position in text.php but it only load 404 - page not found.

How I include the file:

<?php include 'texte/text.php'; ?>

I declare my "start-word" like this:

<a href=“texte/text.php#InfoAnker“>Informationen</a>

And my anchor like this:

<h2 id="InfoAnker"> Informationen </h2>

I also tried <a href=“#InfoAnker“>Informationen</a> because of the include but it came out the same result.

Any ideas?

  • 写回答

2条回答 默认 最新

  • dongshi1102 2019-07-31 11:27
    关注

    If <h2 id="InfoAnker"> Informationen </h2> is generated somewhere within your page and sent to the browser, then an anchor link should work correctly as

    <a href="#InfoAnker">Informationen</a>
    

    One think I noticed from your example is that you should make sure you use " not for quote marks - these are not the same characters, and you must use the correct one.

    Clicking on an anchor link should not result in a 404 error, if it's correctly defined. Even if the anchor ID doesn't actually exist in the page, it still wouldn't give a 404 - the worst that would occur would be that nothing would happen.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭