Quote:
Originally Posted by logic ali
The script will instantly cancel/replace the request or remove the image placeholder.
|
In at least Firefox 2.0, that is not true. The HTTP request is still sent with that script. You also can't cancel a request in HTTP after it is sent.
HTML is parsed from top to bottom. The img element is above the script element, so the img element is reached first. When the img element is reached, it will see what's in the src attribute and make the HTTP request for the image. While the response is being retrieved, the next line is reached in the HTML, but it is already too late for the script to disable it. I can tell this by checking the logs on my server that the image is still requested with this script.
The script (or a portion of it) must therefore be above the img element. The catch is that JavaScript cannot reference elements via document.getElementById() until the browser has parsed it. Maybe there is a way to stop all images on the page ahead of time, let the img element pass, call the script to disable that particular img, and finally reenable the rest of the page's images?
EDITS:
Sorry I didn't state this in my first two posts: I need to stop HTTP request, not just the transfer or visibility of the image.
And to ForestCroce, as far as I can tell, images in <noscript> are not indexed, and I wouldn't be surprised if text was not picked up either. I imagine the rationale behind this is that <noscript> hides stuff from the majority of users, since almost all users have JavaScript enabled. If the majority of users don't see it, then the search engine doesn't need to see it.
Last edited by frost; 07-30-2007 at 11:48 PM..
Reason: more information
|