Img on error works in safari but not firefox,(leopard) what can I doto fix that. - Javascript
This is a discussion on Img on error works in safari but not firefox,(leopard) what can I doto fix that. - Javascript ; I am using Leopard
I found this code and am testing it as is. It works fine on safari
3.0.4 (gives an alert and then changes the missing picture icon to an
actual picture images/2.jpg), but not at all on ...
-
Img on error works in safari but not firefox,(leopard) what can I doto fix that.
I am using Leopard
I found this code and am testing it as is. It works fine on safari
3.0.4 (gives an alert and then changes the missing picture icon to an
actual picture images/2.jpg), but not at all on firefox 2.0.0.10, no
alert, no swap of image (on Leopard). I am testing this because on a
larger script I put a missing image on purpose, firefox triggered the
"onload" fx even though the image was not there and the image shown
was the missing image icon!!? that is strange. On that larger script,
firefox did open an alert window, so that is not the problem?
What else can I use which would work on all browsers? I need the
scripting part mostly so I can preload and check 100s of pictures to
make sure they were all found.
I checked it in jslint, which did not like the inline part, but
removing it did not change anything
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Checking files</title>
<script type="text/javascript">
var imgsrc = 'picture1.gif';
var img = new Image();
img.onerror = function (evt) {
alert(this.src + " can't be loaded.");
};
img.onload = function (evt) {
alert(this.src + " is loaded.");
};
img.src = imgsrc;
</script>
</head>
<body>
<img src="p1.gif" onerror="this.onerror=null;this.src='images/
2.jpg';">
</body>
</html>
-
Re: Img on error works in safari but not firefox,(leopard) what can Ido to fix that.
On Nov 28, 9:42 pm, anne001 <a...@wjh.harvard.edu> wrote:
> I am using Leopard
>
> I found this code and am testing it as is. It works fine on safari
> 3.0.4 (gives an alert and then changes the missing picture icon to an
> actual picture images/2.jpg), but not at all on firefox 2.0.0.10, no
> alert, no swap of image (on Leopard).
In Firefox imgObject.onerror handler is intentionally killed in any
form, even for hardcoded in the source <img> elements (internal
security exception raised) - maybe to prevent any possibility of
content sniffing or I don't know. AFAICT nothing you can do about it.
Either screw on Firefox, or move your logic server-side which is
suggested: so get directory check results from server script over some
ajaxoid.
-
Re: Img on error works in safari but not firefox,(leopard) what can Ido to fix that.
We would like to be compatible to most browsers. So I am interested in
the ajaxoid.
I am new to webprogramming (not to programming). I have several books
on ajax. Could you give me a few keywords to look for?
Right now I don't have a server script. I will have a serverscript to
receive the
user responses (sent through a form post). How would my html interact
with a serverscript on loading the images?
" get directory check results from server script over some ajaxoid"
-
Re: Img on error works in safari but not firefox,(leopard) what can Ido to fix that.
On Nov 28, 10:25 pm, anne001 <a...@wjh.harvard.edu> wrote:
> We would like to be compatible to most browsers. So I am interested in
> the ajaxoid.
>
> I am new to webprogramming (not to programming). I have several books
> on ajax. Could you give me a few keywords to look for?
>
> Right now I don't have a server script. I will have a serverscript to
> receive the
> user responses (sent through a form post). How would my html interact
> with a serverscript on loading the images?
>
> " get directory check results from server script over some ajaxoid"
I am actually surprised myself but this demo is pretty explicit:
<html>
<head>
<title>Demo</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body>
<p><img src="foobar.gif" onerror="alert('error')"
onload="alert('Loaded')"></p>
</body>
</html>
If foobar.gif doesn't exist then onerror handling is silently
supressed in Firefox. Someone in Gecko team has chosen a "simple
solution" for the problem.
So your only option would be then to try to use XmlHttpRequest like
the one on www.ajaxtoolbox.com to see if you can catch 404 Not found
responses
But if XmlHttpRequest even allowed to request binary data? I don't
remember.
-
Re: Img on error works in safari but not firefox,(leopard) what can Ido to fix that.
Thank you so much for your help
-
Re: Img on error works in safari but not firefox,(leopard) what canI do to fix that.
anne001 wrote:
> [...] What else can I use which would work on all browsers?
It is an illusion to think that anything would work on all browsers.
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
-
Re: Img on error works in safari but not firefox,(leopard) what canI do to fix that.
anne001 wrote:
> We would like to be compatible to most browsers. So I am interested in
> the ajaxoid.
To be compatible to most browsers, you will have to abandon the notion of
the "ajaxoid".
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>
-
Re: Img on error works in safari but not firefox,(leopard) what canI do to fix that.
Thomas 'PointedEars' Lahn said the following on 11/29/2007 4:51 PM:
> anne001 wrote:
>> We would like to be compatible to most browsers. So I am interested in
>> the ajaxoid.
>
> To be compatible to most browsers, you will have to abandon the notion of
> the "ajaxoid".
Pure nonsense.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
-
Re: Img on error works in safari but not firefox,(leopard) what canI do to fix that.
Randy Webb wrote:
> Thomas 'PointedEars' Lahn said the following on 11/29/2007 4:51 PM:
>> anne001 wrote:
>>> We would like to be compatible to most browsers. So I am interested in
>>> the ajaxoid.
>> To be compatible to most browsers, you will have to abandon the notion of
>> the "ajaxoid".
>
> Pure nonsense.
It isn't. "Most" means the maximum possible coverage, and XHR ("the
ajaxoid") is not even necessary here.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
-
Re: Img on error works in safari but not firefox,(leopard) what canI do to fix that.
Thomas 'PointedEars' Lahn said the following on 11/30/2007 12:48 PM:
> Randy Webb wrote:
>> Thomas 'PointedEars' Lahn said the following on 11/29/2007 4:51 PM:
>>> anne001 wrote:
>>>> We would like to be compatible to most browsers. So I am interested in
>>>> the ajaxoid.
>>> To be compatible to most browsers, you will have to abandon the notion of
>>> the "ajaxoid".
>> Pure nonsense.
>
> It isn't. "Most" means the maximum possible coverage, and XHR ("the
> ajaxoid") is not even necessary here.
I didn't say it was necessary. I said the notion that to be compatible
to "most browsers" means you have to abandon AJAX is Pure Nonsense. The
term for it is "graceful degradation".
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Similar Threads
-
By Application Development in forum Javascript
Replies: 1
Last Post: 10-20-2007, 04:38 PM
-
By Application Development in forum Javascript
Replies: 1
Last Post: 09-21-2007, 08:59 PM
-
By Application Development in forum Javascript
Replies: 0
Last Post: 09-21-2007, 09:18 AM
-
By Application Development in forum DOTNET
Replies: 2
Last Post: 09-11-2007, 05:20 PM
-
By Application Development in forum Javascript
Replies: 3
Last Post: 12-01-2006, 07:49 AM