Solved

load new index by date range in the month

Posted on 1997-03-28
1
157 Views
Last Modified: 2012-06-21
I have four different index pages.  What I would like to do is use JavaScript to load index1 from the 1st to the 7th, index2 8th to 14th, index3 15th to 21st, index4 22nd to 30/31st.  But I want to make sure the viewer is using Netscape, if not then load which ever index is specify.

Thanks in advance...Allen
ps:  Ina Gardner sent me...
0
Comment
Question by:aj032897
1 Comment
 
LVL 3

Accepted Solution

by:
RM032397 earned 200 total points
ID: 1265066
Here is some code for testing for browsers
// BROWSER TEST
var NN2 = (navigator.appName == "Netscape" &&
navigator.appVersion.substring(0,1) == 2);
var NN3 = (navigator.appName == "Netscape" &&
navigator.appVersion.substring(0,1) == 3);
var NN4 = (navigator.appName == "Netscape" &&
navigator.appVersion.substring(0,1) == 4);
var IE3 = (navigator.appName == "Microsoft Internet Explorer" &&
navigator.appVersion.substring(0,1) == 3);
var NN34 = (NN3 || NN4)

NN34 is true if browser is Netscape 3 or 4
If 2 was OK you could for example have
var NN = (NN2 || NN3 || NN4)

To get the date you extract it from the date object
var dater = new Date ()
var Today = dater.getDate();

Then you have some careful work to do with "if"
var dater = new Date ()
var Today = dater.getDate();
// Then you have some careful work to do with "if"
var NewLoc = ""
if (Today < 8)                             NewLoc = "index1.html"
if ((Today >=  8 ) && (Today < 15 ))       NewLoc = "index2.html"
if ((Today >= 15 ) && (Today < 22 ))       NewLoc = "index3.html"
if ((Today >= 22 ) && (Today < 32 ))       NewLoc = "index4.html"
this.location.href = NewLoc

The way you put the above fragments of code together, depends upon what you mean by "make sure the viewer is using Netscape, if not then load which ever index is specify"

You could use if (NN) {[code a] }  ; else {[code b]}




0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question