Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

load new index by date range in the month

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
aj032897
Asked:
aj032897
1 Solution
 
RM032397Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now