Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Splitting on several lines
Message
De
03/06/2013 03:26:05
 
 
À
02/06/2013 13:09:53
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01575403
Message ID:
01575460
Vues:
33
>>>
>>>return typeof loWindow.pageYOffset != 'undefined' ? loWindow.pageYOffset: document.documentElement.scrollTop?
>>> document.documentElement.scrollTop: document.body.scrollTop? document.body.scrollTop:0
>>>
    if (typeof loWindow.pageYOffset != 'undefined') {
>>        return loWindow.pageYOffset;
>>    }
>>    if (document.documentElement.scrollTop) {
>>        return document.documentElement.scrollTop;
>>    } 
>>    return 0;
>
>Yesterday, I came up with this. I do not think that code takes care of all the possibilities. Mine seems to do so:
>
>
>   function PositionTop()
>   {
>      lnOffset=0
>      loWindow=window.parent.oParent
>      if (loWindow.pageYOffset)
>      {
>         lnOffset=loWindow.document.documentElement.scrollTop
>      }
>      else
>      {
>         lnOffset=loWindow.document.body.scrollTop
>      }
>      return lnOffset
>   }
>
My code is functionally identical to the original. Yours is not : If pageYOffset is available you are returning scrolltop rather than pageYOffset.

Thierry gave you the best solution (but ignored your requirement to use more lines :-})
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform