简体   繁体   English

“图片”和“ ../images”之间资源html差异的路径

[英]Path for resources html difference between “images” and “../images”

I have a html located at www.domain/folderOne. 我有一个位于www.domain / folderOne的html。 My images path's at www.domain/images. 我的图片路径位于www.domain / images。

I found out that the file mywebpage.html located at www.domain/folderOne can get the images displayed with either 我发现位于www.domain / folderOne的文件mywebpage.html可以通过以下任一方式显示图像

<img src="../images/7.jpg" alt="Text" style="width: 800px; height:400px; " id="text">

and

<img src="images/texts/6/7.jpg" alt="Text" style="width: 800px; height:400px; " id="text">

I don't know why both work. 我不知道为什么两者都起作用。 Could anyone provide an answer? 谁能提供答案? As an extra information, I am making the html file change the location displayed in address bar after it is loaded with: 作为额外的信息,我将使html文件在加载后更改地址栏中显示的位置:

<script type="text/javascript">
    history.pushState(null, null, '../SuperWeb');
    window.addEventListener('popstate', function(event) {
    history.pushState(null, null, '../SuperWeb');
    });
</script>

You likely either have a symbolic link in the directory tree that stores your web assets on the server, or a web server mapping (eg, a rewrite rule) that maps calls from one URI to the other. 您可能在目录树中有一个符号链接,该符号树将您的Web资产存储在服务器上,或者在Web服务器映射(例如,重写规则)中将呼叫从一个URI映射到另一个URI。 Hard to know without knowing more about your server setup, but it's not an intrinsic feature of HTML. 在不了解服务器设置的情况下很难知道,但这不是HTML的固有功能。 I will point out that it's a good practice to use site-relative links (eg, /path/img.jpg ) rather than document relative (as you specify above), as it makes it hard to migrate content to different directories. 我将指出,使用站点相对链接(例如/path/img.jpg )而不是使用文档相对的链接(如您在上面指定的)是一种好习惯,因为这样会使内容难以迁移到其他目录。

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

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