gpt4 book ai didi

javascript - html 图像 src 困惑

转载 作者:行者123 更新时间:2023-11-30 23:51:24 26 4
gpt4 key购买 nike

如果我放入 src 属性 ./images/nothing.gif 会翻译成什么?

我有一个 javascript 文件,它将某些 html 元素的 src 属性设置为“nothing.gif”

但在页面上 Nothing.gif 显示为“文件未找到”符号。

目前,nothing.gif 位于我的 ftp 服务器中的以下位置:

/www/foldername/wp-content/themes/themeg/images/nothing.gif

JavaScript 位于:

/www/darksnippets/wp-content/themes/themeg/javascript.js

由于这是 WordPress,因此没有实际的“html 页面”,内容存储在数据库中。所以如果我使用../我应该在哪里放置nothing.gif?

编辑:

这里是页面链接:http://www.darksnippets.com/?page_id=56

nothing.gif 可以在这里找到:http://www.darksnippets.com/wp-content/uploads/nothing.gif

在右下角你会看到 splinter 的图像符号(这在Chrome的IE中显示。在FF中不显示)

最佳答案

相对路径./images/nothing.gif由浏览器而不是服务器解释。所以它会从浏览器的 Angular 查看url来解析路径。浏览器看到的 url 是什么?

更新:

我看到您提供了网址。将相对路径更改为:

./wp-content/uploads/nothing.gif

但更好的解决方案是使用根相对路径。即以 /

开头的

关于javascript - html 图像 src 困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1428017/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com