最近做福建WEB话单功能时发现访问WEB首页时,每个请求会发送2次请求到后台,俺表示非常的费解,用FF debug后现象如下:
发现首页被请求了2次,后来经过调试后发现HTML中有这么一段:
当img标签中src属性为一个空字符串时会产生这个多出来的请求!!
产生此问题的HTML:
straight HTML
<img src="">
JavaScript
var img = new Image();
img.src = "";
产生结果如下:
Internet Explorer makes a request to the directory in which the page is located. 按当前请求目录请求一次,如访问 http://192.168.3.170:81/fuzhou/index.html 则请求http://192.168.3.170:81/fuzhou/
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. 不会请求
分享下原文出处,參考: Yahoo's Best Practices for Speeding Up Your Web Site(http://developer.yahoo.com/performance/rules.html), Avoid Empty Image src
同事的总结,记录一下!很好!
发现首页被请求了2次,后来经过调试后发现HTML中有这么一段:
当img标签中src属性为一个空字符串时会产生这个多出来的请求!!
产生此问题的HTML:
straight HTML
<img src="">
JavaScript
var img = new Image();
img.src = "";
产生结果如下:
Internet Explorer makes a request to the directory in which the page is located. 按当前请求目录请求一次,如访问 http://192.168.3.170:81/fuzhou/index.html 则请求http://192.168.3.170:81/fuzhou/
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. 不会请求
分享下原文出处,參考: Yahoo's Best Practices for Speeding Up Your Web Site(http://developer.yahoo.com/performance/rules.html), Avoid Empty Image src
同事的总结,记录一下!很好!