Results 1 to 2 of 2

Thread: Difficult Javascript Problem!

  1. #1
    Join Date
    Dec 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Difficult Javascript Problem!

    Hi guys,
    Here's one to rack your brains over.
    I want to use a javascript in order to change the color of some text depending on the current date. For example, i want to define 2 dates, and if the current date is within those 2 dates it displays one colored text and if it is outside that date it displays a different colored text.

    To get an example of what i mean go to www.ecampsite.co.uk/somerset.php
    If a campsite is open, the text will be green, and if it is closed it is orange. Is there any way to automate this with javascript??
    Your input regarding this will be invaluable!

    Thank you
    Craig

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ecampsite.co.uk
    I want to use a javascript in order to change the color of some text depending on the current date.
    If you're the maintainer of ecampsite.co.uk, or are otherwise affiliated with it, then you have PHP and therefore you should use that. Rather than using inline style declarations, you might find it easier to apply a class attribute to the entire 'campsite'.

    Some tips:

    • Don't use 'Click here' for link text.
    • Remove the 'Click here to go back' links. They're pointless.
    • The facilities should be marked-up as a list of links. Style them inline afterwards, if you want.
    • The Content-Type header sent by your server states that the character set for the document is ISO-8859-1 (Latin-1), whilst a meta element tries to assert UTF-8. HTTP headers are authorative, and all browsers should ignore the meta element, so if you want UTF-8, modify the server configuration or use PHP to change the header. Either way, omit the element.
    • Your markup is rather broken, with two starting html tags, two head elements, and two title elements. It is also rather out-dated, being littered with deprecated markup.
    • Using client-side scripting in the way you have will not tell you how large the viewport is, so including different style sheets based on that information is a complete waste of time. At least the document doesn't fall apart if client-side scripting is disabled, though.
    • Remove the SGML comments from your script and style elements.
    • _new is not a valid frame target name. If you want a new window, use _blank.
    A final, unrelated point: Bristol is not in the county of Somerset. It is an independant county in itself.

    Mike

Bookmarks

Posting Permissions

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