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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is this possible?

    I have a set of JavaScript countdowns (counting down to different release dates) that I want users to be able to copy and paste a code into there profile (MySpace or whatever) and it will show up. Only problem is that some of the code is in the <HEAD> section and the other half is in the <BODY> section. When I copy both halves and put them together to test them out, it just shows code. Here's the code..


    In the <HEAD> section..

    <SCRIPT LANGUAGE="JavaScript">
    <!--- Hide from non-JavaScript browsers
    function LBP(CurrentDay) {
    var XYear=CurrentDay.getFullYear();
    var XDay=new Date("October, 29, 2008");
    XDay.setFullYear(XYear);
    var DayCount=(XDay-CurrentDay)/(1000*60*60*2...
    DayCount=Math.round(DayCount);
    return DayCount;}
    function MonthTxt (MonthNumber) {
    var Month=new Array();
    Month[1]="January";
    Month[2]="February";
    Month[3]="March";
    Month[4]="April";
    Month[5]="May";
    Month[6]="June";
    Month[7]="July";
    Month[8]="August";
    Month[9]="September";
    Month[10]="October";
    Month[11]="November";
    Month[12]="December";
    return Month[MonthNumber]; }
    //Stop Hiding --->
    </SCRIPT>



    In the <BODY> section..

    <center><h5 style="position: relative; bottom: -35pt; z-index: 2"><font color="blue">
    <script language="JavaScript">
    <!---Hide from non-JavaScript Browsers
    var Today=new Date();
    var ThisDay=Today.getDate();
    var ThisMonth=Today.getMonth()+1;
    var ThisYear=Today.getFullYear();
    var DaysLeft=LBP(Today);
    var MonthName=MonthTxt(ThisMonth);
    <!-- document.write("Today is "+MonthName+" "+ThisDay+"<br>"); -->
    if(DaysLeft > 0) {
    document.write(""+DaysLeft+" days until LittleBigPlanet!");
    } else {
    document.write("LittleBigPlanet is out!");
    }
    //Stop hiding --->
    </script>
    </font></h5></center>



    How can I make a working embed code so people can copy & paste it into there profile and forum signatures? Thanks!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,171
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    Something wrong here!

    var DayCount=(XDay-CurrentDay)/(1000*60*60*2...I think it should it be:-

    var DayCount=(XDay-CurrentDay)/(1000*60*60*24);


    Just move this block:-

    var Today=new Date();
    var ThisDay=Today.getDate();
    var ThisMonth=Today.getMonth()+1;
    var ThisYear=Today.getFullYear();
    var DaysLeft=LBP(Today);
    var MonthName=MonthTxt(ThisMonth);
    <!-- document.write("Today is "+MonthName+" "+ThisDay+"<br>"); -->
    if(DaysLeft > 0) {
    document.write(""+DaysLeft+" days until LittleBigPlanet!");
    } else {
    document.write("LittleBigPlanet is out!");
    }

    to right after:-

    <SCRIPT LANGUAGE="JavaScript">
    <!--- Hide from non-JavaScript browsers

    but the language attribute is deprecated, so change that to

    <script type = "text/javascript">

    Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose.


    The whole aim of practical politics is to keep the populace alarmed (and hence clamorous to be led to safety)
    by menacing it with an endless series of hobgoblins, all of them imaginary.
    H.L. Mencken 1880-1956, American Editor, Author, Critic, Humorist
    Last edited by Philip M; 08-22-2008 at 07:48 AM.


  •  

    Posting Permissions

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