简体   繁体   English

从JS DOM用HTML向上移动目录

[英]Moving up a directory with HTML from JS dom

This is my first time posting so any points would be nice about formatting or what not, but here's my problem anyway. 这是我的第一次发布,因此关于格式设置或其他方面的任何要点都很好,但这仍然是我的问题。

This is my JS Code 这是我的JS代码

document.getElementById('mainnav-up').innerHTML =
"<div class='banner'>" +
"<a href='..\index.html'><div class='button'></div></a>" +
"</div>";

Which places a button on my HTML page under : 该按钮在我的HTML页面上的以下位置放置一个按钮:

home/products/product1.html
<div id="mainnav-up"></div>

but instead of being taken to 但不是被带到

home/index.html

I am instead taken to 我被带到

home/products/..index.html

Which is non-existent. 不存在。 If I then hard code the link into the home/products/product1.html page it takes me to the index page correctly, but I'd like to be able to just edit one piece of code for the whole website. 然后,如果我将链接硬编码到home/products/product1.html页面中,则可以正确地将我带到索引页面,但是我希望能够仅编辑整个网站的一段代码。

Change 更改

<a href='..\index.html'>

to

<a href='../product1.html'>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM