开发者

Text citation for every day of the year

I would like to to put on very page of my site (开发者_运维知识库mscperu.org) on the header as include page a different text citation for every day of the year.

I found "image changing every day of the year" but I'm no pro so I do not know how to change the javascript so it may bring up a text citation for every day of the year.


Haaaah, you sure are vague my friend. Basicaly there's two ways to accomplish what you want here

  1. You have all the 365 texts for each day of the year placed each inside a separate div element, each div with a different id (like id=day1, id=day2 etc). Then you make a small javascript function which is called each tiem a page is loaded, gets the current date, and unhides the corresponding div. Problem with this is that

p1a. You have a ton of non visible text that is still there in the page to be loaded, so it takes more time for the page to load.

p1b. It depends on what date the person who currently visits your page has on his/hers computer. If it's the wrong date, they'll see the wrong message

  1. A better way to do this, but more involved is to have a server side component (like a php script or a java servlet) attached to an url, (like /messageOfTheDay.html) and then in your web page, you'd have javascript that gets the message from that component and displays it in the page on each load. It will be up to the server side component to figure out the date and what message to send.

There's multiple advantages with this setup:

2a. You get to send only usable text, and not the entire list of messages 2b. You no longer depend on the visitor's computer's date, it's your server date (possibly combined with the client's time zone) to decide what's the current date and what message to send 3c. YOu can make it such (wiht Ajax) the message is autoamtically changes to the new one if the date changes, so that a user will see the new message without having to reload the page.

If this is confusing, send me an email, and I'll give you an actual example code in java or php (u'r choice), since you seem to be a good person, ok?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜