I'm loading (large) images dynamically to draw into a html5 canvas, something like this:
var t = new Image();
t.onload = ...
t.src = 'http://myurl';
But every once in a while would like to cancel the image request completely.
The only way I came up with is setting src
to ''
. i.e.
t.src = ''
This works in many browsers, but it seems that only Firefox actually cancels the http request for the image.
I tested this with Fiddler2 by disabling caching and enabling "emulate modem speed". Then running a fiddle to test canceling a image request. (I'd love to hear other ideas on how to test this)
I know there are ways to cancel all requests (as in this question), but I'd like to only cancel one.
Any ideas on other ways (especially on mobile browsers) to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…