Internet Explorer requests a different URL for images with blank src tags than most other browsers
For Images with no "src" parameter, Internet Explorer requests a different URL than most other browsers. Firefox, Opera, and most other browsers request the same page that was requested. Internet Explorer, though, requests the directory of the current page.
The behaviour of both browsers is somewhat strange. If an image has a blank "src" attribute, I would think that logically, the browser shouldn't attempt to display it. But whey would it try to look up the same page it just displayed (most browsers) or the parent directory (IE). Neither of which are logical choices.
Discuss this on my blog post about it
Reset both counters
Reload
The behaviour of both browsers is somewhat strange. If an image has a blank "src" attribute, I would think that logically, the browser shouldn't attempt to display it. But whey would it try to look up the same page it just displayed (most browsers) or the parent directory (IE). Neither of which are logical choices.
Discuss this on my blog post about it
| Blank Image: |
This image has a blank "src" parameter |
| Most Browsers will request: | /examples/ie_blank_img_src_tag/index.php |
| Internet Explorer requests: | /examples/ie_blank_img_src_tag/ |
Usage tests
The following table describes how PHP sessions could be affected by the differences.|
Continuous count is 1 |
Submit count is is 0 |
|
| Functionality | This number is incremented on every page load |
This number is incremented on every page load if it has "?param" in the URL It is reset to 0 when the page is requested without "?param" in the URL |
| IE Behavior | This number is incremented once when the page is loaded and another time when the browser hits the same URL for the blank image. You should see it go up by two numbers each time the page is loaded. | This number is incremented to 1 if you hit the submit button. Then when IE requests the image, without any parameters, it resets it back to zero. The next time you load the page, it is incremented to 1 again. If you load this page by hitting the "Reload" link (not the button), it will stay at zero |
| Behavior of other browsers | This number is incremented once when the page is loaded and another time when the browser hits the same URL for the blank image. You should see it go up by two numbers each time the page is loaded. | This number is incremented once when the page is loaded and another time when the browser hits the same URL for the blank image |
Effects
The effects this may have on your site vary depending on what you are trying to do, but here are a few things that you may notice:- You notice double-hits in your access logs
- It may appear that PHP Sessions aren't working, or have really wierd, unexplainable session stuff happening.
- In the example that inspired me to investigate, a report was being generated based on parameters in the GET request. IE was fetching the image (the script without any parameters) and resetting the report back to default. It looked like PHP sessions weren't working in IE, despite confirm that the session was being created and saved correctly
Here is the functional PHP code. It's a bit contrived, but gives you working example
<?php
session_start();
if(isset($_GET['reset'])) {
$_SESSION['submit'] = 0;
$_SESSION['continuous'] = 0;
header("Location: http://www.brandonchecketts.com/examples/ie_blank_img_src_tag/index.php");
exit;
}
if(isset($_GET['param'])) {
$_SESSION['submit'] = isset($_SESSION['submit']) ? $_SESSION['submit'] + 1 : 1;
} else {
$_SESSION['submit'] = 0;
}
$_SESSION['continuous'] = isset($_SESSION['continuous']) ? $_SESSION['continuous'] + 1 : 1;
?>