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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onload jump to calculated anchor

    Hi

    I have a calendar, an html page that writes the whole month from three .js files. There's a named anchor at the start of each day:
    <a name="' + day + '"></a>
    When the page loads I would like it to arrive at the anchor for today's date (day)
    I'm sure this must be easy, I just can't get it to work
    any ideas?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Idea #1: A link is worth a thousand words.
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, sorry, did that not make any sense. I can't put the actual link up I'm afraid as it's a work calendar and the boss won't appreciate it. I'll try to explain a bit more clearly...#

    I have "What's On Today" 3 javascript files that load taday's info into the main page. If you click the title bar it jumps to a new page uses the same code but displays every day this month. I want it to scroll to today's date when you arrive at the monthly diary, rather than showing you 1st September when it's already the 27th.

    month.htm runs three .js files:
    the first is all the regular events
    the second is all the stuff about what day today is and leap years etc.
    the third writes the html code for the page and ends with...

    document.write(diary);

    The original html page that we started with loads the three .js files in the <head> tag, and the body tag looks like this

    <body onload="document.write(diary);document.close();"></body>

    I've tried various ways of adding something like...

    window.location='#day';

    as 'day' is the variable for today and each named anchor is named by this variable like this...

    '<a name="' + day + '"></a>'

    Like I said I'm sure it should be easy I just don't know the syntax.
    There's my thousand words, a link sure would have been easier...

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This should have been server side application.
    <body onload="document.write(diary);document.close();"></body> - overwrites existing page, adding anything here is useless
    Just add something like that: <a href="#today">Go to todays events</a> to the top of your diary code - it is a extra click, but it also is an easy solution....
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #5
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Vladdy

    That's certainly an option but it already does that - the front page already shows todays events. I just want the monthly diary to display more relevantly, so you can see the next few days or scroll back up to see what you've missed rather than arriving at the first of the month. There must be a way


  •  

    Posting Permissions

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