Solved

load new index by date range in the month

Posted on 1997-03-28
1
156 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

808 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