[jQuery] Re: Change stylesheets if images are off

2008-02-18 Thread Danny
Unfortunately, no. You can't tell whether a .load will fail until it does fail, and that's true of any asynchronous method. You can't say if it's failed or just not succeeded yet. All you can do is set a time limit and check if you've succeeded in that time and if not, assume you've failed. That's

[jQuery] Re: Change stylesheets if images are off

2008-02-17 Thread [EMAIL PROTECTED]
Yet another question about this (or perhaps about Javascript in general) ... Am I missing something that's staring me in the face, or is it really not possible to make a function that goes something like jQuery.fn.afunction(animage) { if ! $(animage).load(function() { . do stuff be

[jQuery] Re: Change stylesheets if images are off

2008-02-16 Thread Danny
One thing I realized, is that it will still have a delay from page load to running the images-enabled function--the browser has to request the nonexistent image, get the 404 Not Found response, then execute the onerror. So you may well have a flash of 'noimages.css' before 'gotimages.css' are load

[jQuery] Re: Change stylesheets if images are off

2008-02-16 Thread [EMAIL PROTECTED]
OMG, I can't wait to test this!!! On Feb 17, 5:12 am, Danny <[EMAIL PROTECTED]> wrote: > A simple hack to detect if images are enabled: > Include the following in your HTML: > http://microsoft.com/nothing.gif"; onerror="alert('hello');" > style="position: absolute;top=-100px" /> > > If images are

[jQuery] Re: Change stylesheets if images are off

2008-02-16 Thread Danny
A simple hack to detect if images are enabled: Include the following in your HTML: http://microsoft.com/nothing.gif"; onerror="alert('hello');" style="position: absolute;top=-100px" /> If images are enabled, we waste microsoft's bandwidth for a bit (it could be any nonexistent image file on any s

[jQuery] Re: Change stylesheets if images are off

2008-02-16 Thread [EMAIL PROTECTED]
Oops, set typing in motion before engaging brain Setting 'On' will defeat the object :o What I mean to say is, I set the initial css to 'gotimages'. I still sometimes see a flash of the 'noimages' style (on a slow connection, with cache disabled) and will certainly be delighted if anyone com

[jQuery] Re: Change stylesheets if images are off

2008-02-16 Thread [EMAIL PROTECTED]
Oops, set typing in motion before engaging brain Setting 'On' will defeat the object :o Stupid idea! On Feb 16, 2:04 pm, "Richard D. Worth" <[EMAIL PROTECTED]> wrote: > On Feb 15, 2008 6:55 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> > wrote: > > > > > > > I finally finished it > > > //

[jQuery] Re: Change stylesheets if images are off

2008-02-16 Thread [EMAIL PROTECTED]
You're right about the imagefree stylesheet trying to load, the hack helps here! You can set its initial value to 'On' ;) There is a flash effect if you then switch between images on & off. (Not likely to happen in production, though far from ideal of course). I absolutley couldn't get this to w

[jQuery] Re: Change stylesheets if images are off

2008-02-16 Thread Richard D. Worth
On Feb 15, 2008 6:55 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I finally finished it > > // detect whether images are on > // and change styles accordingly > jQuery.imagesOn = function(){ > > $(' >' ).load(function() { > $('#noimages').attr("href", '/styles/gotimages.

[jQuery] Re: Change stylesheets if images are off

2008-02-16 Thread George
Interesting idea Cherry, Have you noticed whether the imagefree.css starts to load anyway before the href is changed to gotimages.css? (I'd expect the if- statement to run before the load() callback function). In IE you could try the error event as the alternative condition. Can't remember what