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 to the CF scene
    Join Date
    Mar 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I add <br> and a link in this script? Am A Newbie

    Hi, I haver this script which works great. I would like to add a <br> command in to add other text as a seperate paragraph and also I would like to include a some text which can also act as a link. Could anyone advise please, I would appreciate your help. I am a complete novice at this stuff.

    Code:
    <script language="JavaScript">
    <!--
    calendar = new Date();
    day = calendar.getDay();
    month = calendar.getMonth();
    date = calendar.getDate();
    year = calendar.getYear();
    if (year< 100) year = 1900 + year;
    cent = parseInt(year/100);
    g = year % 19;
    k = parseInt((cent - 17)/25);
    i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
    i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
    j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
    l = i - j;
    emonth = 3 + parseInt((l + 40)/44);
    edate = l + 28 - 31*parseInt((emonth/4));
    emonth--;
    var dayname = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
    var monthname =
    new Array ("January","February","March","April","May","June","July","August","September","October","November","December" );
    document.write(dayname[day]+", ");
    document.write(date+" ");
    document.write(monthname[month]+" ");
    document.write(+"2007");
    // January is month 0
    if ((month == 0) && (date == 1)) document.write(" - Mary, Mother of God");
    document.write("<br></font>");
    //-->
    </script>
    I have every day of the year, but thought that would be too long to include the whole lot.! LOL!

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    I'm not sure where you want to inject it, but seems it's just using document.write to make new html. (which is generally not a good thing any more, BTW, it's better to use DOM methods or innerHTML if you can)

    document.write("<br>");

    That writes the break.
    You can just write out <a href='whatever'>link</a> and so on however you like.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by nikkiH View Post
    I'm not sure where you want to inject it, but seems it's just using document.write to make new html. (which is generally not a good thing any more, BTW, it's better to use DOM methods or innerHTML if you can)

    document.write("<br>");

    That writes the break.
    You can just write out <a href='whatever'>link</a> and so on however you like.
    Thank you for that. I have one small problem however. How do I fet the link I have created to open out of the Iframe that I have.

    To explain, I have the above script in a file called date.htm - I then have an Iframe on my index.htm page that calls the scripts results to go into. That works great. However, when I click on the link that now appears, it opens up in the Iframe on my index.htm page. I would like it to open up in its own page, but without having two pages open at once. I hope that made sense.

    Sorry, I am stupid I know!

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    try: <a href="whatever.html" target="_top">link</a>

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts

    Smile

    give your iframe an id then set the target of the link to that id!
    i think that makes sense

  • #6
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    I think the OP wanted the opposite? For the link to open in the main window, not the iframe?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by nikkiH View Post
    I think the OP wanted the opposite? For the link to open in the main window, not the iframe?
    I think so.
    Code:
    <a href="whatever" target="_top">link</a>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Yep, that's what I had.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/


  •  

    Posting Permissions

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