Javascript doesn't work in newer Mozillas...

Discussion in 'Javascript' started by Cat, Jan 21, 2005.

  1. Cat

    Cat Guest

    Greetings,

    I have an old javascript effect that was running on some of my
    sites for quite long, working fine in Netscape (up to 4.75) and
    IE. It still works in the newer IEs, but not in the new Mozillas,
    neither Firebird nor Firefox (and not in Netscape 7.something).

    What is wrong with it? I'm no javascript expert, I just got it
    from the net years ago, I don't even know where from. There is
    no source url given in it to look up. I've added the code below.

    I have exactly the same situation with two other scripts - they
    worked for years and suddenly they seem to be 'expired' for Mozilla.
    I think it's the same problem with all, so I hope if someone gives
    me a helping hand with this one I might fiddle out the other two
    as well.

    Sorry for the long babble, and thanks to anyone who has the patience
    to look over it,

    Cat



    <BODY BGCOLOR="#000000" ONLOAD="fly()">

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    SmallStars = 27;
    LargeStars = 3;
    SmallYpos = new Array();
    SmallXpos = new Array();
    LargeYpos = new Array();
    LargeXpos = new Array();
    Smallspeed= new Array();
    Largespeed= new Array();
    ns=(document.layers)?1:0;
    if (ns) {
    for (i = 0; i < SmallStars; i++) {
    document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#EEDBDB'
    CLIP='0,0,1,1'></LAYER>");
    }
    for (i = 0; i < LargeStars; i++) {
    document.write("<LAYER NAME='ln"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0'
    CLIP='0,0,2,2'></LAYER>");
    }
    }
    else {
    document.write('<div style="position:absolute;top:0px;left:0px">');
    document.write('<div style="position:relative">');
    for (i = 0; i < SmallStars; i++) {
    document.write('<div id="si"
    style="position:absolute;top:0;left:0;width:1px;height:1px;background:#fffff0;font-size:1px"></div>');
    }
    document.write('</div>');
    document.write('</div>');
    document.write('<div style="position:absolute;top:0px;left:0px">');
    document.write('<div style="position:relative">');
    for (i = 0; i < LargeStars; i++) {
    document.write('<div id="li"
    style="position:absolute;top:0;left:0;width:2px;height:2px;background:#ffffff;font-size:2px"></div>');
    }
    document.write('</div>');
    document.write('</div>');
    }
    WinHeight =
    (document.layers)?window.innerHeight:window.document.body.clientHeight;
    WinWidth =
    (document.layers)?window.innerWidth:window.document.body.clientWidth;
    for (i = 0; i < SmallStars; i++) {
    SmallYpos = Math.round(Math.random() * WinHeight);
    SmallXpos = Math.round(Math.random() * WinWidth);
    Smallspeed= Math.random() * 5 + 1;
    }
    for (i = 0; i < LargeStars; i++) {
    LargeYpos = Math.round(Math.random() * WinHeight);
    LargeXpos = Math.round(Math.random() * WinWidth);
    Largespeed = Math.random() * 10 + 5;
    }
    function fly() {
    var WinHeight =
    (document.layers)?window.innerHeight:window.document.body.clientHeight;
    var WinWidth =
    (document.layers)?window.innerWidth:window.document.body.clientWidth;
    var hscrll =
    (document.layers)?window.pageYOffset:document.body.scrollTop;
    var wscrll =
    (document.layers)?window.pageXOffset:document.body.scrollLeft;
    for (i = 0; i < LargeStars; i++) {
    LargeXpos -= Largespeed;
    if (LargeXpos < -10) {
    LargeXpos = WinWidth;
    LargeYpos = Math.round(Math.random() * WinHeight);
    Largespeed = Math.random() * 10 + 5;
    }
    if (ns) {
    document.layers['ln'+i].left = LargeXpos;
    document.layers['ln'+i].top = LargeYpos + hscrll;
    }
    else {
    li.style.pixelLeft = LargeXpos;
    li.style.pixelTop = LargeYpos + hscrll;
    }
    }
    for (i = 0; i < SmallStars; i++) {
    SmallXpos -= Smallspeed;
    if (SmallXpos[i] < -10) {
    SmallXpos[i] = WinWidth;
    SmallYpos[i] = Math.round(Math.random()*WinHeight);
    Smallspeed[i] = Math.random() * 5 + 1;
    }
    if (ns) {
    document.layers['sn'+i].left = SmallXpos[i];
    document.layers['sn'+i].top = SmallYpos[i]+hscrll;
    }
    else {
    si[i].style.pixelLeft = SmallXpos[i];
    si[i].style.pixelTop = SmallYpos[i]+hscrll;
    }
    }
    setTimeout('fly()', 10);
    }
    // End -->


    </SCRIPT>[/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
    Cat, Jan 21, 2005
    #1
    1. Advertising

  2. Cat

    Richard Guest

    On Fri, 21 Jan 2005 15:36:03 +0100 Cat wrote:

    > Greetings,


    > I have an old javascript effect that was running on some of my
    > sites for quite long, working fine in Netscape (up to 4.75) and
    > IE. It still works in the newer IEs, but not in the new Mozillas,
    > neither Firebird nor Firefox (and not in Netscape 7.something).


    Maybe due to the ancient ways of doing things.

    document.write('</div>');
    document.write('</div>');
    document.write('<div style="position:absolute;top:0px;left:0px">');
    document.write('<div style="position:relative">');


    Convert all of this stuff into css.
    <div> should come before </div> not as you show it.

    in css it would look like
    div.sample { position:absolute; top:0px; left;0px; }

    <div class="sample">text</div>

    You might want to brush up on existing acceptable JS conventions.
    Then tweak your script accordingly.
    Richard, Jan 21, 2005
    #2
    1. Advertising

  3. Cat

    Robert Guest

    In article <>, Cat <> wrote:

    > Greetings,
    >
    > I have an old javascript effect that was running on some of my
    > sites for quite long, working fine in Netscape (up to 4.75) and
    > IE. It still works in the newer IEs, but not in the new Mozillas,
    > neither Firebird nor Firefox (and not in Netscape 7.something).


    This script contains the Netscape 4.x layer tag. This tag was dropped
    from the Gekco base browsers. Netscape 6.x, firefox, etc. This is the
    reason for the failure.

    Rbert
    Robert, Jan 21, 2005
    #3
  4. Cat

    Spats30 Guest

    Couple of things: almost no-one is supporting NS 4.x vesions anymore.
    It's usage is nominal, anymore, so remove it.

    Then what is happening in your script is that the logic checks for old
    NS versions (document.layers), if found, then use these specific old NS
    properties, else assume IE and use proprietary IE properties. Newer NS
    and Firefox browsers follow the ECMA standards better and don't support
    either set of proprietary properties used in your script.

    What you should do is search for a whole new script, or go through
    manually, and replace anything with document.layers with new code
    supported by NS 6+. It would take a long time to be more specific for
    this post, but followup on your own and you'll learn a lot along the
    way.



    Cat wrote:
    > Greetings,
    >
    > I have an old javascript effect that was running on some of my
    > sites for quite long, working fine in Netscape (up to 4.75) and
    > IE. It still works in the newer IEs, but not in the new Mozillas,
    > neither Firebird nor Firefox (and not in Netscape 7.something).
    >
    > What is wrong with it? I'm no javascript expert, I just got it
    > from the net years ago, I don't even know where from. There is
    > no source url given in it to look up. I've added the code below.
    >
    > I have exactly the same situation with two other scripts - they
    > worked for years and suddenly they seem to be 'expired' for Mozilla.
    > I think it's the same problem with all, so I hope if someone gives
    > me a helping hand with this one I might fiddle out the other two
    > as well.
    >
    > Sorry for the long babble, and thanks to anyone who has the patience
    > to look over it,
    >
    > Cat
    >
    >
    >
    > <BODY BGCOLOR="#000000" ONLOAD="fly()">
    >
    > <SCRIPT LANGUAGE="JavaScript">
    > <!-- Begin
    > SmallStars = 27;
    > LargeStars = 3;
    > SmallYpos = new Array();
    > SmallXpos = new Array();
    > LargeYpos = new Array();
    > LargeXpos = new Array();
    > Smallspeed= new Array();
    > Largespeed= new Array();
    > ns=(document.layers)?1:0;
    > if (ns) {
    > for (i = 0; i < SmallStars; i++) {
    > document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#EEDBDB'
    > CLIP='0,0,1,1'></LAYER>");
    > }
    > for (i = 0; i < LargeStars; i++) {
    > document.write("<LAYER NAME='ln"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0'
    > CLIP='0,0,2,2'></LAYER>");
    > }
    > }
    > else {
    > document.write('<div style="position:absolute;top:0px;left:0px">');
    > document.write('<div style="position:relative">');
    > for (i = 0; i < SmallStars; i++) {
    > document.write('<div id="si"
    >

    style="position:absolute;top:0;left:0;width:1px;height:1px;background:#fffff0;font-size:1px"></div>');
    > }
    > document.write('</div>');
    > document.write('</div>');
    > document.write('<div style="position:absolute;top:0px;left:0px">');
    > document.write('<div style="position:relative">');
    > for (i = 0; i < LargeStars; i++) {
    > document.write('<div id="li"
    >

    style="position:absolute;top:0;left:0;width:2px;height:2px;background:#ffffff;font-size:2px"></div>');
    > }
    > document.write('</div>');
    > document.write('</div>');
    > }
    > WinHeight =
    >

    (document.layers)?window.innerHeight:window.document.body.clientHeight;
    > WinWidth =
    > (document.layers)?window.innerWidth:window.document.body.clientWidth;
    > for (i = 0; i < SmallStars; i++) {
    > SmallYpos = Math.round(Math.random() * WinHeight);
    > SmallXpos = Math.round(Math.random() * WinWidth);
    > Smallspeed= Math.random() * 5 + 1;
    > }
    > for (i = 0; i < LargeStars; i++) {
    > LargeYpos = Math.round(Math.random() * WinHeight);
    > LargeXpos = Math.round(Math.random() * WinWidth);
    > Largespeed = Math.random() * 10 + 5;
    > }
    > function fly() {
    > var WinHeight =
    >

    (document.layers)?window.innerHeight:window.document.body.clientHeight;
    > var WinWidth =
    > (document.layers)?window.innerWidth:window.document.body.clientWidth;
    > var hscrll =
    > (document.layers)?window.pageYOffset:document.body.scrollTop;
    > var wscrll =
    > (document.layers)?window.pageXOffset:document.body.scrollLeft;
    > for (i = 0; i < LargeStars; i++) {
    > LargeXpos -= Largespeed;
    > if (LargeXpos < -10) {
    > LargeXpos = WinWidth;
    > LargeYpos = Math.round(Math.random() * WinHeight);
    > Largespeed = Math.random() * 10 + 5;
    > }
    > if (ns) {
    > document.layers['ln'+i].left = LargeXpos;
    > document.layers['ln'+i].top = LargeYpos + hscrll;
    > }
    > else {
    > li.style.pixelLeft = LargeXpos;
    > li.style.pixelTop = LargeYpos + hscrll;
    > }
    > }
    > for (i = 0; i < SmallStars; i++) {
    > SmallXpos -= Smallspeed[i];
    > if (SmallXpos[i] < -10) {
    > SmallXpos[i] = WinWidth;
    > SmallYpos[i] = Math.round(Math.random()*WinHeight);
    > Smallspeed[i] = Math.random() * 5 + 1;
    > }
    > if (ns) {
    > document.layers['sn'+i].left = SmallXpos[i];
    > document.layers['sn'+i].top = SmallYpos[i]+hscrll;
    > }
    > else {
    > si[i].style.pixelLeft = SmallXpos[i];
    > si[i].style.pixelTop = SmallYpos[i]+hscrll;
    > }
    > }
    > setTimeout('fly()', 10);
    > }
    > // End -->
    >
    >
    > </SCRIPT>[/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
    [i][i][i][i][i][i][i][i][i][i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
    Spats30, Jan 21, 2005
    #4
  5. Cat

    Lee Guest

    Robert said:
    >
    >In article <>, Cat <> wrote:
    >
    >> Greetings,
    >>
    >> I have an old javascript effect that was running on some of my
    >> sites for quite long, working fine in Netscape (up to 4.75) and
    >> IE. It still works in the newer IEs, but not in the new Mozillas,
    >> neither Firebird nor Firefox (and not in Netscape 7.something).

    >
    >This script contains the Netscape 4.x layer tag. This tag was dropped
    >from the Gekco base browsers. Netscape 6.x, firefox, etc. This is the
    >reason for the failure.


    Since there is no document.layers object, it doesn't detect modern
    Netscape as being Netscape at all, and so it never writes the LAYER
    tags. It writes the IE code, instead.

    However, even the IE code is garbage. It creates multiple <div>
    tags with the same ID and then refers to them as elements of a
    global array by the name of that ID tag.

    It's pretty sad that IE tolerates this garbage.

    You would be better off find new code. This sort of thing should be
    available.
    Lee, Jan 21, 2005
    #5
  6. Cat

    RobB Guest

    Lee wrote:
    > Robert said:
    > >
    > >In article <>, Cat <> wrote:
    > >
    > >> Greetings,
    > >>
    > >> I have an old javascript effect that was running on some of my
    > >> sites for quite long, working fine in Netscape (up to 4.75) and
    > >> IE. It still works in the newer IEs, but not in the new Mozillas,
    > >> neither Firebird nor Firefox (and not in Netscape 7.something).

    > >
    > >This script contains the Netscape 4.x layer tag. This tag was

    dropped
    > >from the Gekco base browsers. Netscape 6.x, firefox, etc. This is

    the
    > >reason for the failure.

    >
    > Since there is no document.layers object, it doesn't detect modern
    > Netscape as being Netscape at all, and so it never writes the LAYER
    > tags. It writes the IE code, instead.
    >
    > However, even the IE code is garbage. It creates multiple <div>
    > tags with the same ID and then refers to them as elements of a
    > global array by the name of that ID tag.
    >
    > It's pretty sad that IE tolerates this garbage.
    >
    > You would be better off find new code. This sort of thing should be
    > available.


    Lee pretty much covered it ('garbage')...in addition, the script is
    written in such a way as to optimize differences in animation
    efficiencies between (some) browsers, making any sort of uniform
    timebase a kludge at best. style.pixelLeft/Top are IE-only. In any
    event...dumped the LAYERS, cleaned it up a bit. Whatever.

    <html>
    <head>
    <title>untitled</title>
    </head>
    <body bgcolor="#000000"
    onresize="window.location.reload()"
    onload="setInterval('fly()', window.createPopup?80:1);"><!-- a little
    speed equalization -->
    <script type="text/javascript">

    var SmallStars = 27;
    var LargeStars = 3;
    var SmallYpos = [];
    var SmallXpos = [];
    var LargeYpos = [];
    var LargeXpos = [];
    var Smallspeed = [];
    var Largespeed = [];
    document.write(
    '<div style="position:absolute;top:0px;left:0px;">',
    '<div style="position:relative;">'
    );
    for (i = 0; i < SmallStars; i++) {
    document.write(
    '<div id="si' + i + '" ',
    'style="position:absolute;top:0;left:0;',
    'width:1px;height:1px;background:#fff;',
    'font-size:1px;"></div>'
    );
    }
    document.write(
    '</div>','</div>',
    '<div style="position:absolute;top:0;left:0;">',
    '<div style="position:relative;">'
    );
    for (i = 0; i < LargeStars; i++) {
    document.write(
    '<div id="li' + i + '" ',
    'style="position:absolute;top:0;left:0;',
    'width:2px;height:2px;background:#fff;',
    'font-size:2px;"></div>'
    );
    }
    document.write('</div>','</div>');
    WinHeight = ('undefined' != typeof window.innerHeight)?
    window.innerHeight : document.body.clientHeight;
    WinWidth = ('undefined' != typeof window.innerWidth)?
    window.innerWidth-5 : document.body.clientWidth-5;
    for (i = 0; i < SmallStars; i++) {
    SmallYpos = Math.round(Math.random() * WinHeight);
    SmallXpos = Math.round(Math.random() * WinWidth);
    Smallspeed= Math.random() * 5 + 1;
    }
    for (i = 0; i < LargeStars; i++) {
    LargeYpos = Math.round(Math.random() * WinHeight);
    LargeXpos = Math.round(Math.random() * WinWidth);
    Largespeed = Math.random() * 10 + 5;
    }

    function fly() {
    var hscrll = ('undefined' != typeof window.pageYOffset)?
    window.pageYOffset : document.body.scrollTop;
    var wscrll = ('undefined' != typeof window.pageXOffset)?
    window.pageXOffset : document.body.scrollLeft;
    for (i = 0; i < LargeStars; i++) {
    LargeXpos -= Largespeed;
    if (LargeXpos < -10) {
    LargeXpos = WinWidth;
    LargeYpos = Math.round(Math.random() * WinHeight);
    Largespeed = Math.random() * 10 + 5;
    }
    }
    i = 0;
    while (li = document.getElementById('li' + i)) {
    li.style.left = LargeXpos + 'px';
    li.style.top = LargeYpos[i++] + hscrll + 'px';
    }
    for (i = 0; i < SmallStars; i++) {
    SmallXpos -= Smallspeed;
    if (SmallXpos < -10) {
    SmallXpos = WinWidth;
    SmallYpos = Math.round(Math.random()*WinHeight);
    Smallspeed = Math.random() * 5 + 1;
    }
    }
    i = 0;
    while (si = document.getElementById('si' + i)) {
    si.style.left = SmallXpos + 'px';
    si.style.top = SmallYpos[i++] + hscrll + 'px';
    }
    }

    </script>
    </body>
    </html>
    RobB, Jan 21, 2005
    #6
  7. Cat

    Randy Webb Guest

    Richard wrote:
    > On Fri, 21 Jan 2005 15:36:03 +0100 Cat wrote:
    >
    >
    >>Greetings,

    >
    >
    >>I have an old javascript effect that was running on some of my
    >>sites for quite long, working fine in Netscape (up to 4.75) and
    >>IE. It still works in the newer IEs, but not in the new Mozillas,
    >>neither Firebird nor Firefox (and not in Netscape 7.something).

    >
    >
    > Maybe due to the ancient ways of doing things.
    >
    > document.write('</div>');
    > document.write('</div>');
    > document.write('<div style="position:absolute;top:0px;left:0px">');
    > document.write('<div style="position:relative">');
    >
    >
    > Convert all of this stuff into css.
    > <div> should come before </div> not as you show it.


    To the OP: Ignore the above advice. If Richard had bothered to *read*
    the code, he would have noticed that it does indeed have them in the
    correct order. It's typical of his hairbrained replies.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Randy Webb, Jan 21, 2005
    #7
  8. Cat

    RobB Guest

    (snip)

    OK, cleaned this up a bit. Beware of lunatic line breaking courtesy of
    googlegroups (turn on error reporting and look for unterminated
    strings).

    <html>
    <head>
    <title>untitled</title>
    </head>
    <body style="background:#000;"
    onresize="window.location.reload()"
    onload="if(document.getElementById)setInterval('fly()', 40)">
    <script type="text/javascript">

    var SmallStars = 27;
    var LargeStars = 3;
    var SmallYpos = [];
    var SmallXpos = [];
    var LargeYpos = [];
    var LargeXpos = [];
    var Smallspeed = [];
    var Largespeed = [];
    document.write(
    '<div style="position:absolute;top:0px;left:0px;">',
    '<div style="position:relative;">'
    );
    for (i = 0; i < SmallStars; i++) {
    document.write(
    '<div id="si' + i + '" ',
    'style="position:absolute;top:0;left:0;',
    'width:1px;height:1px;background:#fff;',
    'font-size:1px;"></div>'
    );
    }
    document.write(
    '</div>','</div>',
    '<div style="position:absolute;top:0;left:0;">',
    '<div style="position:relative;">'
    );
    for (i = 0; i < LargeStars; i++) {
    document.write(
    '<div id="li' + i + '" ',
    'style="position:absolute;top:0;left:0;',
    'width:2px;height:2px;background:#fff;',
    'font-size:2px;"></div>'
    );
    }
    document.write('</div>','</div>');
    WinHeight = ('undefined' != typeof window.innerHeight)?
    window.innerHeight : document.body.clientHeight;
    WinWidth = ('undefined' != typeof window.innerWidth)?
    window.innerWidth-5 : document.body.clientWidth-5;
    for (i = 0; i < SmallStars; i++) {
    SmallYpos = Math.round(Math.random() * WinHeight);
    SmallXpos = Math.round(Math.random() * WinWidth);
    Smallspeed= Math.random() * 5 + 1;
    }
    for (i = 0; i < LargeStars; i++) {
    LargeYpos = Math.round(Math.random() * WinHeight);
    LargeXpos = Math.round(Math.random() * WinWidth);
    Largespeed = Math.random() * 10 + 5;
    }

    function fly() {
    var hscrll = ('undefined' != typeof window.pageYOffset)?
    window.pageYOffset : document.body.scrollTop;
    var wscrll = ('undefined' != typeof window.pageXOffset)?
    window.pageXOffset : document.body.scrollLeft;
    for (i = 0; i < LargeStars; i++) {
    LargeXpos -= Largespeed;
    if (LargeXpos < -10) {
    LargeXpos = WinWidth;
    LargeYpos = Math.round(Math.random() * WinHeight);
    Largespeed = Math.random() * 10 + 5;
    }
    }
    i = 0;
    while (li = document.getElementById('li' + i)) {
    li.style.left = LargeXpos + 'px';
    li.style.top = LargeYpos[i++] + hscrll + 'px';
    }
    for (i = 0; i < SmallStars; i++) {
    SmallXpos -= Smallspeed;
    if (SmallXpos < -10) {
    SmallXpos = WinWidth;
    SmallYpos = Math.round(Math.random()*WinHeight);
    Smallspeed = Math.random() * 5 + 1;
    }
    }
    i = 0;
    while (si = document.getElementById('si' + i)) {
    si.style.left = SmallXpos + 'px';
    si.style.top = SmallYpos[i++] + hscrll + 'px';
    }
    }

    </script>
    </body>
    </html>
    RobB, Jan 22, 2005
    #8
  9. Cat

    Cat Guest

    Hi,

    thank you so very much for this, it works like a charm now.
    I read the newsgroups in my old Netscape 4.8 still, so I don't
    have problems with the linebreaks.

    I will go through it and see where you made changes, hopefully
    I learn something from it. For some reason, Javascript, like
    cgi, comes terribly hard to me, even though I love to use it.
    Maybe because it has something to do with logic, that's just not
    my world (I'm a former painter that started out as a designer,
    still longing for the brushes..;)

    Thanks again,

    Cat



    RobB wrote:
    >
    > (snip)
    >
    > OK, cleaned this up a bit. Beware of lunatic line breaking courtesy of
    > googlegroups (turn on error reporting and look for unterminated
    > strings).
    >
    > <html>
    > <head>
    > <title>untitled</title>
    > </head>
    > <body style="background:#000;"
    > onresize="window.location.reload()"
    > onload="if(document.getElementById)setInterval('fly()', 40)">
    > <script type="text/javascript">
    >
    > var SmallStars = 27;
    > var LargeStars = 3;
    > var SmallYpos = [];
    > var SmallXpos = [];
    > var LargeYpos = [];
    > var LargeXpos = [];
    > var Smallspeed = [];
    > var Largespeed = [];
    > document.write(
    > '<div style="position:absolute;top:0px;left:0px;">',
    > '<div style="position:relative;">'
    > );
    > for (i = 0; i < SmallStars; i++) {
    > document.write(
    > '<div id="si' + i + '" ',
    > 'style="position:absolute;top:0;left:0;',
    > 'width:1px;height:1px;background:#fff;',
    > 'font-size:1px;"></div>'
    > );
    > }
    > document.write(
    > '</div>','</div>',
    > '<div style="position:absolute;top:0;left:0;">',
    > '<div style="position:relative;">'
    > );
    > for (i = 0; i < LargeStars; i++) {
    > document.write(
    > '<div id="li' + i + '" ',
    > 'style="position:absolute;top:0;left:0;',
    > 'width:2px;height:2px;background:#fff;',
    > 'font-size:2px;"></div>'
    > );
    > }
    > document.write('</div>','</div>');
    > WinHeight = ('undefined' != typeof window.innerHeight)?
    > window.innerHeight : document.body.clientHeight;
    > WinWidth = ('undefined' != typeof window.innerWidth)?
    > window.innerWidth-5 : document.body.clientWidth-5;
    > for (i = 0; i < SmallStars; i++) {
    > SmallYpos = Math.round(Math.random() * WinHeight);
    > SmallXpos = Math.round(Math.random() * WinWidth);
    > Smallspeed= Math.random() * 5 + 1;
    > }
    > for (i = 0; i < LargeStars; i++) {
    > LargeYpos = Math.round(Math.random() * WinHeight);
    > LargeXpos = Math.round(Math.random() * WinWidth);
    > Largespeed = Math.random() * 10 + 5;
    > }
    >
    > function fly() {
    > var hscrll = ('undefined' != typeof window.pageYOffset)?
    > window.pageYOffset : document.body.scrollTop;
    > var wscrll = ('undefined' != typeof window.pageXOffset)?
    > window.pageXOffset : document.body.scrollLeft;
    > for (i = 0; i < LargeStars; i++) {
    > LargeXpos -= Largespeed;
    > if (LargeXpos < -10) {
    > LargeXpos = WinWidth;
    > LargeYpos = Math.round(Math.random() * WinHeight);
    > Largespeed = Math.random() * 10 + 5;
    > }
    > }
    > i = 0;
    > while (li = document.getElementById('li' + i)) {
    > li.style.left = LargeXpos + 'px';
    > li.style.top = LargeYpos[i++] + hscrll + 'px';
    > }
    > for (i = 0; i < SmallStars; i++) {
    > SmallXpos -= Smallspeed;
    > if (SmallXpos < -10) {
    > SmallXpos = WinWidth;
    > SmallYpos = Math.round(Math.random()*WinHeight);
    > Smallspeed = Math.random() * 5 + 1;
    > }
    > }
    > i = 0;
    > while (si = document.getElementById('si' + i)) {
    > si.style.left = SmallXpos[i] + 'px';
    > si.style.top = SmallYpos[i++] + hscrll + 'px';
    > }
    > }
    >
    > </script>
    > </body>
    > </html>[/i]
    Cat, Jan 22, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yan-Hong Huang[MSFT]
    Replies:
    3
    Views:
    485
    Yan-Hong Huang[MSFT]
    Jul 4, 2003
  2. =?Utf-8?B?bV9sYWNp?=
    Replies:
    2
    Views:
    501
    =?Utf-8?B?bV9sYWNp?=
    Oct 15, 2004
  3. Guest

    Sucking mozillas...

    Guest, Sep 26, 2005, in forum: HTML
    Replies:
    52
    Views:
    1,718
    Jim Higson
    Oct 2, 2005
  4. Casey Hawthorne
    Replies:
    1
    Views:
    413
    Gerhard Häring
    Jan 24, 2009
  5. Kate Riley

    disable JavaScript in newer browsers

    Kate Riley, Jul 23, 2003, in forum: Javascript
    Replies:
    2
    Views:
    75
    Kate Riley
    Jul 23, 2003
Loading...

Share This Page