/    Sign up×
Community /Pin to ProfileBookmark

Scrolling stars not working on php pages

Hello, I don’t know if anyone here will answer since the last post was 3 months ago, but if anyone is still around to, please help me figure out how to make this scrolling stars script wrok with my SMF forum php pages.

<!– TWO STEPS TO INSTALL SPACE TRIP:

  • 1. Add the onLoad event handler into the BODY tag

  • 2. Copy the coding into the BODY of your HTML document –>
  • <!– STEP ONE: Insert the onLoad event handler into your BODY tag –>

    <BODY BGCOLOR=”#000000″ onLoad=”fly()”>

    <!– STEP TWO: Paste this code into the BODY of your HTML document –>

    <SCRIPT LANGUAGE=”JavaScript”>
    <!– Original: Kurt Grigg ([email protected]) –>
    <!– Web Site: [url]http://website.lineone.net/~kurt.grigg/javascript[/url] –>

    <!– This script and many more are available free online at –>
    <!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>

    <!– Begin
    SmallStars = 30;
    LargeStars = 10;
    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=’#FFFFF0′ CLIP=’0,0,1,1’></LAYER>”);
    }
    for (i = 0; i < LargeStars; i++) {
    document.write(“<LAYER NAME=’ln”+i+”‘ LEFT=0 TOP=0 BGCOLOR=’#FFFFFF’ 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[i] = Math.round(Math.random() * WinHeight);
    SmallXpos[i] = Math.round(Math.random() *
    WinWidth);
    Smallspeed[i]= Math.random() * 5 + 1;
    }
    for (i = 0; i < LargeStars; i++) {
    LargeYpos[i] = Math.round(Math.random() *
    WinHeight);
    LargeXpos[i] = Math.round(Math.random() * WinWidth);
    Largespeed[i] = 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[i] -= Largespeed[i];
    if (LargeXpos[i] < -10) {
    LargeXpos[i] = WinWidth;
    LargeYpos[i] = Math.round(Math.random() * WinHeight);
    Largespeed[i] = Math.random() *
    10 + 5;
    }
    if (ns) {
    document.layers[‘ln’+i].left = LargeXpos[i];
    document.layers[‘ln’+i].top = LargeYpos[i] + hscrll;
    }
    else {
    li[i].style.pixelLeft = LargeXpos[i];
    li[i].style.pixelTop = LargeYpos[i] + hscrll;
    }
    }
    for (i = 0; i < SmallStars; i++) {
    SmallXpos[i] -= 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>

    <p><center>
    <font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
    by <a href=”http://javascriptsource.com”>The JavaScript Source</a></font>
    </center><p>

    <!– Script Size: 3.79 KB –>

    Thanks in advance for any help with this

    to post a comment
    JavaScript

    8 Comments(s)

    Copy linkTweet thisAlerts:
    @CrazyMerlinMay 29.2007 — put all the javascript in an external js file.

    at the top of the file put:
    <i>
    </i>window.onload = fly();


    in your php when the page content has been created, add to it:
    [code=php]
    $js_load = "<script type='text/javascript src='name of external js file'></script>";

    $content .= $js;
    [/code]


    ...where $content is the name of the variable that holds the page content.

    If you don't have any luck, let me know where it is you want the code added to, as I run an SMF forum myself, so I can look in the code.
    Copy linkTweet thisAlerts:
    @goitaloneauthorMay 29.2007 — I couldn't get it to work. I wanted it to be on all my forums pages as the main background for all of them.

    I am not sure I did what you correctly...what did you mean by that>>

    where $content is the name of the variable that holds the page content.
    Copy linkTweet thisAlerts:
    @goitaloneauthorMay 30.2007 — You still working on it man? Anyone else here know how to get this to work?
    Copy linkTweet thisAlerts:
    @goitaloneauthorMay 31.2007 — Hello again, I am still not able to get this script to work with my SMF.

    I am just replying to try and bump this back up to the top so someone might see it as I haven't heard anything from anyone and I am afraid my thread will be burried without a resolution.

    Sorry, and thank you for your understanding.

    I really wish I could find a way soon to get this to work for my site as it will be a new theme for my users. thanks!

    goitalone
    Copy linkTweet thisAlerts:
    @goitaloneauthorJun 02.2007 — Anyone?
    Copy linkTweet thisAlerts:
    @goitaloneauthorJun 13.2007 — Sorry, to bother you again with this but I still can't get this script to work on my SMF...can anyone please give me some ideas at least how I might try and get this to work?

    Thanks!
    Copy linkTweet thisAlerts:
    @smeezekittyJun 13.2007 — try inserting this in your page <script type='text/javascript'>onload=fly()</script>
    Copy linkTweet thisAlerts:
    @rootJun 13.2007 — try inserting this in your page <script type='text/javascript'>onload=fly()</script>[/QUOTE]
    that attaches to the "Document" not the window, you have to specify window.onload=fly; to invoke the function when the window has opened.
    ×

    Success!

    Help @goitalone spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...