用于创建书签的HTML链接在首次点击时无效,但可在第二次点击时使用

时间:2017-08-17 22:42:28

标签: html

我有以下HTML文档 -

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <p><a href="#C20">Jump to chapter20</a></p>
   
    <h2>Chapter1</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter2</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter3</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter4</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter5</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter6</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter7</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter8</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter9</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter10</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter11</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter12</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter13</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter14</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter15</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter16</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter17</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter18</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter19</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter20</h2>
    <p id="C20">This chapter explains bla bla bla</p>
</body>
</html>

当我在google-chrome浏览器中打开文档时,我会看到一个网页。它的截图是 -

enter image description here

这里的URL是:

http://127.0.0.1:46661/1.html

点击链接时没有任何反应。

截图 -

enter image description here

此处网址已更改为 http://127.0.0.1:46661/1.html#C20

当我再次点击它这次工作的链接时。

截图 -

enter image description here

网址保持不变。

为什么我的浏览器会显示这种奇怪的行为?

1 个答案:

答案 0 :(得分:-1)

请尝试以下操作。

&#13;
&#13;
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <p><a href="#C20">Jump to chapter20</a></p>

    <h2>Chapter1</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter2</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter3</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter4</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter5</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter6</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter7</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter8</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter9</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter10</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter11</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter12</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter13</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter14</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter15</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter16</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter17</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter18</h2>
    <p>This chapter explains bla bla bla</p>

    <h2>Chapter19</h2>
    <p>This chapter explains bla bla bla</p>

    <h2 id="C20">Chapter20</h2>
    <p>This chapter explains bla bla bla</p>
</body>
</html>
&#13;
&#13;
&#13;