我的HTML中有以下代码:
I do have the following code in my HTML:
<img src="#" alt="image alternative text" />src =#均值?因为在HTML中,图像标签不能包含空的 src 属性。如果我们没有这个属性,visual studio 2012会提出一个建议。
What does src="#" mean? Because in HTML, I cannot have empty src attribute for an image tag. And if we do not have that attribute, visual studio 2012 will throw a suggestion.
谢谢
Thanks
推荐答案如果您不想使用src属性加载任何图像(稍后可能会动态加载图像),则需要将src设置为空。但是,当你这样做时,浏览器仍然会向服务器发送调用。
When you don't want any image to be loaded using src attribute (probably load the image dynamically later), you need to set src empty. But when you do that, browsers still send calls to server.
空src的浏览器行为(来源: developer.yahoo/performance/rules.html )
Browser behavior for empty src (Source: developer.yahoo/performance/rules.html)
Internet Explorer向页面所在的目录发出请求。 Safari和Chrome向本身的实际页面发出请求。 Firefox 3和更早版本的行为与Safari和 Chrome相同,但版本3.5解决了此问题[错误444931]并且不再有发送请求。当遇到空白图像src时,Opera不会执行任何操作。
Internet Explorer makes a request to the directory in which the page is located. Safari and Chrome make a request to the actual page itself. Firefox 3 and earlier versions behave the same as Safari and Chrome, but version 3.5 addressed this issue[bug 444931] and no longer sends a request. Opera does not do anything when an empty image src is encountered.
为了避免不必要的服务器调用,使用空的src,可以使用 src =#,它形成一个哈希URL并且哈希URL不会被发送到服务器。
To avoid the unnecessary call to server, instead of using empty src, src="#" could be used which forms a hash url and hash urls are not sent to server.
让我们说基地网址是: mysite/myapp/
Let's say base url is : mysite/myapp/
src = - >绝对网址: mysite/myapp/
src="" -> Absolute url: mysite/myapp/
src =# - >绝对网址: mysite/myapp/ #
src="#" -> Absolute url: mysite/myapp/#
更多推荐
< img src ="#">在HTML中意味着什么?
发布评论