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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题