Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Colorado, USA
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question onload to onclick....

    Objectives; Convert onload to onclick and unload by onclick, including when onload statement is absent from script. Must not auto start at page load, but still should terminate with page exit. Need individual link to invoke each event desired and and auto terminate any possible running event before initiating new event. I only want one event running at any time or no event.
    Site visitor point-of-view, to be able to select special effects on a singular page at will or choose no special effects to view the page in a “normal” manner without having to load a new page for every effect.
    As a beginner any advice and tips from the learned veterans is greatly appreciated.
    Thanks in advance.
    Editor; FrontPage 2002 (included in Office XP). Personal Operating System; Windows XP and ME. Browsers; Latest versions, NN, IE and Opera. Server running; RedHat Linux 7.2

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    well, without having the effects you want in front of me, the system i suggest would be to have the desired effect tacked onto the end of the url, using the search string. say your page is thePage.htm, you tack th effect onto it like this: thePage.htm?effectName

    then, you have a little piece of javascript, that checks to see if anything is tacked onto the URL, reads that info if there is any, checks it against an array of effects, and takes the appropriate action.

    writing the links would then be as simple as linking to the current page, and tacking the appropriate effect name onto the end of it, using a question mark. because the page has to reload every time, two effects couldn't run simultaneously, and including a link that didn't have anything tacked onto it would allow the viewer to see the page with no effects at all.

    whether that would work or not could depend on the effects you want to use. was the first thing that came to mind, though.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    New Coder
    Join Date
    Jun 2002
    Location
    Colorado, USA
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The effects I intend to use are weather effects mostly by just basic scripts with a small image file and some also with a class file. If it is needed I can post the scripts as this site is a WIP and not online yet, but I hesitated to do that in the initial post because it would tend to make it a miles long. I intend the page to initially load with just common text, background and images. I am trying to avoid having to load a new page for, let’s say viewing the scene with a lightning storm. Also if for no other reason running more than one effect at a time is really not an option because they can be very resource intensive. I am thinking of the average visitors computing power and bandwidth (I have gigs of this and that and multi broadband). I will monitor this post often. Thanks..
    Following is sample basic page also "lightning" "Fall" samples.

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <style fprolloverstyle>A:hover {color: red; font-weight: bold}
    </style>
    </head>

    <body background="images/Page1(index)/homebg.jpg" bgcolor="#0066FF">

    <div align="center">
    <center>
    <table border="0" cellspacing="0" cellpadding="0" id="AutoNumber1" style="border-collapse: collapse" bordercolor="#111111">
    <tr>
    <td align="center" nowrap><span style="letter-spacing: 8pt"><font size="7" face="Woodcut"><b>
    Welcome</b></font></span></td>
    </tr>
    </table>
    </center>
    </div>
    <div align="center">
    <center>
    <table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" id="AutoNumber2">
    <tr>
    <td align="center" nowrap><font face="FederationStarfleetSquare" size="4">N</font></td>
    <td rowspan="2" align="center" nowrap><font face="FederationStarfleetSquare">
    <span style="letter-spacing: 2pt">ewmatesHome</span></font><span style="font-size: 12.0pt; font-family: Times New Roman">
    ~&nbsp; </span><span style="letter-spacing: 1pt">
    <font face="FederationStarfleet" size="2">a personal website</font></span></td>
    </tr>
    </table>
    </center>
    </div>

    <p><a href="index.htm">Home</a></p>
    <p><a href="page2.htm">Inside Colorado</a></p>
    <p><a href="page3.htm">Photos</a></p>

    <p><a href="page4.htm">Fun Page</a></p>

    <p><a href="page5.htm">Links</a></p>

    <p><a href="page5.htm">Download</a></p>

    </body>
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    <applet code="lightning.class" width="500" height="125">
    <param name="DELAY" value="2"><img src="lightning.gif" align="bottom"> </font></h1>

    <p><font color="#FFFFFF">You will need a Java-enabled browser to see the lightning applet.
    </applet>
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    <script language="JavaScript">
    <!-- Adapted from the Fall script -->
    <!-- Original script by Kurt Grigg (kurt.grigg@virgin.net) -->

    Amount=20;
    Image0=new Image();
    Image0.src="file1";
    Image1=new Image();
    Image1.src="file2";

    grphcs=new Array(2)
    grphcs[0]="file1"
    grphcs[1]="file2"

    Ypos=new Array();
    Xpos=new Array();
    Speed=new Array();
    Step=new Array();
    Cstep=new Array();
    ns=(document.layers)?1:0;

    if (ns)
    {for (i = 0; i < Amount; i++)
    {var P=Math.floor(Math.random()*grphcs.length);
    rndPic=grphcs[P];
    document.write("<layer name='sn"+i+"' left=0 top=0><img src="+rndPic+"></LAYER>");}}

    else
    {document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
    for (i = 0; i < Amount; i++){
    var P=Math.floor(Math.random()*grphcs.length);
    rndPic=grphcs[P];
    document.write('<img id="si" src="'+rndPic+'" style="position:absolute;top:0px;left:0px">');}
    document.write('</div></div>');}

    WinHeight=(document.layers)?window.innerHeight:window.document.body.clientHeight;
    WinWidth=(document.layers)?window.innerWidth:window.document.body.clientWidth;
    for (i=0; i < Amount; i++)
    {Ypos[i] = Math.round(Math.random()*WinHeight);
    Xpos[i] = Math.round(Math.random()*WinWidth);
    Speed[i]= Math.random()*3+2;
    Cstep[i]=0;
    Step[i]=Math.random()*0.1+0.05;}

    function fall()
    {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 < Amount; i++)
    {sy = Speed[i]*Math.sin(90*Math.PI/180);
    sx = Speed[i]*Math.cos(Cstep[i]);
    Ypos[i]+=sy;
    Xpos[i]+=sx;
    if (Ypos[i] > WinHeight)
    {Ypos[i]=-60;
    Xpos[i]=Math.round(Math.random()*WinWidth);
    Speed[i]=Math.random()*5+2;}
    if (ns)
    {document.layers['sn'+i].left=Xpos[i];
    document.layers['sn'+i].top=Ypos[i]+hscrll;}
    else
    {si[i].style.pixelLeft=Xpos[i];
    si[i].style.pixelTop=Ypos[i]+hscrll;}
    Cstep[i]+=Step[i];}
    setTimeout('fall()',10);}

    //-->
    </script>
    Last edited by newmate; 06-15-2002 at 11:50 PM.
    Editor; FrontPage 2002 (included in Office XP). Personal Operating System; Windows XP and ME. Browsers; Latest versions, NN, IE and Opera. Server running; RedHat Linux 7.2

  • #4
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    so are they all applets, or what?
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #5
    New Coder
    Join Date
    Jun 2002
    Location
    Colorado, USA
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by joh6nn
    so are they all applets, or what?
    I believe so, just the common snow, lightning etc accessing small image files and some use class files. The rain mod can use just text symbols for the rain drops or can also source an image file.
    I wanted to use a lake effect, but I think that is for another day and or page.I know this would be easer if I just created a page for each effect on my server and just linked to them so you could show me mod the page code. I have family looking eagerly looking everyday for my first creation and well you know how that is….

  • #6
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    k. pseudo code as follows.

    <script>
    var theEffects = new Array();
    theEffects[0] = bigLongStringOfHTMLforApplet1;
    theEffects[1] = bigLongStringOfHTMLforApplet2;
    theEffects[2] = bigLongStringOfHTMLforApplet3;
    if ( window.location.search ) {
    var temp = window.location.search.slice(1) - 0;
    document.write(theEffects[temp]);
    }
    </script>

    the bigLongStringsofHTMLforApplet 's take the following form:

    theEffects[0] = '<applet code=\"lightning.class\" width=\"500\" height=\"125\"><param name=\"DELAY\" value=\"2\"><img src=\"lightning.gi\f" align=\"bottom\"></applet>';

    escape the quotes (ie, put a \ in front of them), and make sure there are no line breaks in the string.

    then, your links work like this:
    <A HREF="thePageThisIsOn.htm?1">Effect 1</A>

    <A HREF="thePageThisIsOn.htm?2">Effect 2</A>

    <A HREF="thePageThisIsOn.htm?3">Effect 3</A>
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #7
    New Coder
    Join Date
    Jun 2002
    Location
    Colorado, USA
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow, thanks “joh6nn”. You explained that so well that even I got it straight away, I think.
    One question. If I read this correctly I will be unloading a page and loading a new page for each event. In consideration for low bandwidth visitors is it possible to keep the main page (rather large file) and load and unload the events only?
    PS. "bigLongStringOfHTML"

  • #8
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    well, essentially, that's what you're doing. what you're doing, is taking the same page, and reloading it every time. so, the only thing that changes, is the effect that gets used. all of the other content would be cached after the first time, so people with dial up connections would still be doing ok.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •