Google Answers Logo
View Question
 
Q: javascript ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: javascript
Category: Computers > Programming
Asked by: swykpisz-ga
List Price: $2.00
Posted: 28 Feb 2003 19:36 PST
Expires: 30 Mar 2003 19:36 PST
Question ID: 169068
how do you display a different link for each day?
Answer  
Subject: Re: javascript
Answered By: j_philipp-ga on 28 Feb 2003 22:54 PST
Rated:5 out of 5 stars
 
Hello Swykpisz,

Use the following HTML page:

---

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Sample: Your Daily Link</title>
</head>
<body>

<h1>Sample: Your Daily Link</h1>

<script type="text/javascript"><!--

var linkList = new Array();
var i = 1;
var todaysLink = "";
var linkHtml = "";
var dateNow = new Date();
var dayOfMonth = dateNow.getDate();

linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.org";
linkList[i++] = "http://example.net";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.org";
linkList[i++] = "http://example.net";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.org";
linkList[i++] = "http://example.net";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.org";
linkList[i++] = "http://example.net";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.org";
linkList[i++] = "http://example.net";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.org";
linkList[i++] = "http://example.net";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.org";
linkList[i++] = "http://example.net";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.org";
linkList[i++] = "http://example.net";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.org";
linkList[i++] = "http://example.net";
linkList[i++] = "http://www.example.com";
linkList[i++] = "http://www.example.com";

todaysLink = linkList[dayOfMonth];
linkHtml += "<a href='" + todaysLink + "'>Today's link is "
linkHtml += todaysLink + "</a> ";
document.write(linkHtml);

// --></script>

</body>
</html>

----

This client-side JavaScript displays a different link for each day of
the month. You can test the effect by setting your calendar to a
different day and refreshing the page. Now all that is left for you to
do is to enter the 31 different links (just replace the part above
that reads e.g. "http://www.example.com").


Hope this helps!

Request for Answer Clarification by swykpisz-ga on 01 Mar 2003 06:23 PST
Will this work with inline frames? If so how?

Clarification of Answer by j_philipp-ga on 02 Mar 2003 00:23 PST
Hello Swykpisz,

Yes, it would work with inline frames as well. Since an inline frame
is just a way of including a page, you could also execute same
JavaScript above within this framed page.

For example, name above file "day_link.html". Then save below source
as "index.html":

---

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head>
    <title>Sample Page</title> 
</head> 
<body>
 
<iframe src="day_link.html" title="Link of the Day" width="300"
height="200">
    <a href="day_link.html">Link of the Day</a>
</iframe>

</body> 
</html>

---

Hope it helps!
swykpisz-ga rated this answer:5 out of 5 stars
You answered my question completely, thanks

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy