Web Analytics Made Easy -
StatCounter code to run script on a given date? - CodingForum


No announcement yet.

code to run script on a given date?

  • Filter
  • Time
  • Show
Clear All
new posts

  • code to run script on a given date?

    Hey ya'll,

    I currently am using a PVII script on my page.
    It runs using this...

    <body onload="P7AniMagic('JS',200,0,10,30,1,1000)">

    Now what this does is move a layer 200px after a delay of 1 sec.
    What I'd like to do is...

    setup a javascript that says


    if date is 26,10,2006 run "P7AniMagic('JS',100,0,10,30,1,1000)"

    else if date is 28,10,2006 run "P7AniMagic('JS',120,0,10,30,1,1000)"

    else if date is 30,10,2006 run "P7AniMagic('JS',140,0,10,30,1,1000)"

    Can some kind soul show me how to create such a code - I'm just not up to par on js yet!

    Thank you!

  • #2
    Here you go.

    PHP Code:
    title>Launch on Date</title>
    script type="text/javascript"><!--
    d=new Date();
        for (var 
    i=dates.length-1;i>-1;i--)if (d==dates[i][0])dates[i][1]();
    body onload="testDate()">
    Note: This will run the P7AniMagic only on the 26th, 28th and 30th... not on 27th or 29th... Is that what you wanted?


    • #3
      VortexCortex ur an absolute star!

      I changed the first date to

      to see if it moved today and it did!

      P.S. Yes I only wanted it to run on certain days..

      Shame there's no rating system here! U'd get 5 from me!
      Last edited by dommy; Oct 5, 2006, 07:12 PM.


      • #4
        LOL, I knew you'ld be back for a range of days.

        Originally posted by dommy via PM
        Hi VortexCortex,
        If date is between 25,10,2006 and 30,10,2006 then run run "P7AniMagic('JS',100,0,10,30,1,1000)"
        you could just add more date lines to the prevoius code...
        Notice: the last one does not have a comma "," at the end of the line.

        Or you could rewrite the code to test for a range between two dates.
        <title>Launch on Date</title>
        <script type="text/javascript"><!--
        function testDate(){
            var d=new Date();
            var dates=[
        	function inRange(){
        		var x = new Array();
        		for(var i=0;i<2;i++){
        			x[i] = arguments[i];
        			x[i] = new Date(x[i][2],x[i][1]-1,x[i][0]);
        		return ((d.getTime() >= x[0].getTime()) && (d.getTime() <= x[1].getTime()));
        	var doWork=function(){};
            for (var i=0;i<dates.length;i++)if (inRange(dates[i][0],dates[i][1]))doWork=dates[i][2];
        <body onload="testDate()">
        You can add more date tests to this code as well...
        In The above code: if today lies between two different ranges, only the last range specified in the list has its p7AniMagic called...

        So, if you want the whole month to use one p7aniMagic, and use another for the 2nd thru 6th, and use nothing at all on the 4th use dates ranges like this:
            var dates=[
        Note... you can put whatever code you want between the { } in "funciton{p7AniMagic...}" and the code will get executed.
        function{alert('Hi!');} would work bring up an alert box..
        would redirect to another page.

        PM me if you need more help with this code.


        • #5
          Thanks VortexCortex... I'll have a test with this tonight. I gathered the simple way would have been to write out each date.. but when the code needs to run over 5 months - the code would get too heavy.

          I'll post back tomorrow - cheers mate!
          P.S. Check the nominate thread - ur in there!
          P.S.S. PM me ur msn/yahoo etc IM email - would love to have u in there!.. maybe you could help with another problem I've been having. lol.


          • #6
            You can add to VortexCortex's reputation by clicking the scale icon in the bottom left of the post.

            If you PM each other no one else will be able to follow this thread
            The silent one.

            The most dangerous thing in the world is an idea.
            The most dangerous person in the world is the one with an idea.


            • #7
              Mr J - The entire thread discussion is here - right up to the fix. I just wanted his personal IM for the future...