[Javascript] An image loader nearly working except for IE

Guillaume javascript at webdesignofficina.com
Sun Jul 17 08:12:36 CDT 2005


Dear Troy,

Thank you for your reply, i added a few comments below...

> All right, cliche does not mean no value strait ahead.
> Taking pictures of nature is a cliche already, but taking great 
> pictures of nature, is an art.


Ooops... there was not any negative value for the use of "cliche", 
sorry... I used it my french mind where a cliche first means the object, 
the photography... But you can also use it to denote something that has 
a negative value in the sense you hear it...

>
> The script I mentioned earlier is made for maps, scout maps etc., but 
> it is very suitable for other pictures that don't fit your screen also.
> it should be 100% compatible with NN and IE all versions, not sure 
> about others.
> here it is: (for aesthetic reasons please declare 
> style="overflow:hidden" in the <Body> tag)
>
> var x, y, dx, dy, dB=document.body;
> function enableMove(){
>         dB.style.cursor="move" //can't make it work!
>                                x=event.screenX
>         y=event.screenY
>         dx=x+dB.scrollLeft
>         dy=y+dB.scrollTop
>     }
> function movingNow(){
> if (window.event.button==1) {
>         x=event.screenX
>         y=event.screenY
>        dB.scrollLeft = 0-(x-dx)
>        dB.scrollTop  = 0-(y-dy)
>        dB.style.cursor="move"
>         }
>     }
>
> function setItBack(){dB.style.cursor='';}
> function retF(){return false}
>
> document.onmousedown  =enableMove
> document.onmousemove  =movingNow
> document.onmouseup    =setItBack
> document.onselectstart=retF
> document.ondragstart  =retF


Troy, i really don't get the point of this script... Does this method 
can be used to preload images ? I'm sorry but my skills are limited and 
maybie i'm missing something obvious...

>
> [notice: if you have other window independable objects in the page 
> (like inputs etc) this script might return some errors,

Yes, i do have inputs on the page i will build with this script...

> because selection will not be disabled for this type of objects by 
> this script and by default]
> you may remove the set cursor lines in order to cut the script shorter.
>
> I believe that making scripts targeting one browser only, is one of 
> the best ways to go.
> but this mean that you always have to create the snifer page that will 
> direct the user browser to the right scipts and the right page 
> dependable to the broser system hitting it.

Not if we can make it go cross-browser... Ie is only missing in the list 
of working browsers. J. Lester came up with a version of the script that 
has downsides on a user-friendly level,  but that is apparently 
perfectly working, including Ie. The only way to make IE catch it is the 
use of this line ( inside the J. Lester script ) :

// xPloder doesn't handle onload very well, 
//onreadystatechange is more accurate [tested to work in xPloder 5/5.5/6]
      if (img.onreadystatechange)
         img.onreadystatechange = function() { if (this.readyState == 'complete') document.getElementById('mask').style.display = 'none'; };


As you mentioned this property in an earlier mail, I'd like to have your 
thoughts about this...


> The 'this.complete' is god choice (almost universal) but the weaknes 
> is in the fact that it does not ocure as event. So you have to check 
> its state continuously. (I hate timers, they slow the system down)  
> but it reveals it self as the last resort in this casse.


We could mix it with the onreadystatechange mentioned above to make it 
go cross-browser...

>
> Waiting to see your modified script


I'll try to add the lines mentioned above to target IE and i'll let you 
know.

Thank you very much.

Regards.

Guillaume.










More information about the Javascript mailing list