when you call second html page from a link, second html page must be reload once
second.html
page load once when I call from first.html through the link like
<a href="second.html">Second page</a>
I am using
<a onclick="location.href='second.html'" >
its work fine but i want proper solution how can i load second page aromatically
答案 0 :(得分:0)
首先,您需要了解相对链接和绝对链接之间的区别
相对路径
index.html
/graphics/image.png
/help/articles/how-do-i-set-up-a-webpage.html
绝对路径
http://www.example.com/graphics/image.png
http://www.example.com/help/articles/how-do-i-set-up-a-webpage.html
绝对路径很容易知道单击时元素将指向哪个链接。它永远不会改变。
但是有时您会想要进行更改,例如在开发本地网站时还是在将网站置于在线状态时。
因此,相对路径是最好的选择。但是,您必须始终考虑自己的结构。您的起点将是您输入的文件。
因此,如果您的结构是:
├── root/
│ ├── index.html
├── templates/
└── secondpage.html/
在index.html,您可以建立这样的链接
<a href="./templates/secondpage.html">Second page</a>
不需要任何javascript:)