关于img src值为空时,2次请求有关问题的深入调研

关于img src值为空时,2次请求问题的深入调研

http://hi.baidu.com/bdui/blog/item/9f6ed4af65c349cf7cd92a1f.html
关于img src值为空时,2次请求问题的深入调研
2007-12-11 10:35

以前应该有同学遇到过类似的情况当有一个类似如 <img src=’’> 的标签时会对页面多出一次请求,

根据一篇文章的分析,我猜测是不是所有的会主动引入外部文件的标签都会存在此类问题 embed, link,

于是就以实验的方式加以验证.

以下是初步的结论:

 

 

标签\请求次数\浏览器

IE

FF

演示链接

Img

2

2

http://www.ismvv.cn/test/test.php?tag=img

Embed

1

2

http://www.ismvv.cn/test/test.php?tag=embed

Background: url

1

2

http://www.ismvv.cn/test/test.php?tag=background

Link

1

2

http://www.ismvv.cn/test/test.php?tag=link

Input type=’image’

2

2

http://www.ismvv.cn/test/test.php?tag=input

Script

1

2

http://www.ismvv.cn/test/test.php?tag=script

bgsound

2

http://www.ismvv.cn/test/test.php?tag=bgsound

 

:

1.       对于IEfirefox2次请求两者请求的页面是不一样的.
IE: 
请求的是被访问文件所在的目录, img标签时, 2次请求为 http://www.ismvv.cn/test/
FF: 
请求的是被访问的文件

2.       对于embed标签,上面所描述的情况是在 type 不为空的情况下, type为空时,FF请求1, IE根据type值不同情况不同.

3.       如果 以上的标签中 不包含 src=”” ,就不会发生二次请求.

 

欢迎大家补充,谢谢~