1 Attachment(s)
Open web page according to day
I'm a newbie who wish that each time a user open my web page (Tia Lele - Inicio) it redirects/open on the SAME window to a sub-page that include the menu of the DAY (Monday, Tuesday...) How do I do that? What is wrong? I have been trying without success...please help
(Thank you)
That's what I did:
Code :
<script type="text/javascript">
var current= new Date()
var day=current.getDay()
if (day=0)
window.navigate("http://tialele.weebly.com/lunes.html")
if (day=1)
window.navigate("http://tialele.weebly.com/martes.html")
if (day=2)
window.navigate("http://tialele.weebly.com/miercoles.html")
if (day=3)
window.navigate("http://tialele.weebly.com/jueves.html")
if (day=4)
window.navigate("http://tialele.weebly.com/viernes.html")
if (day=5)
window.navigate("http://tialele.weebly.com/platillos.html")
if (day=6)
window.navigate("http://tialele.weebly.com/platillos.html")
</script>
Re: Open web page according to day
javascript != java (and these are java forums). It might be more useful to try a javascript forum. That being said, you should be able to change the location using the following syntax
Code :
if ( day == 0 )//note the ==
//change location
I've never used window.navigate, but you might achieve the same results with something like
Code :
window.location = "my new location";
Javascript can be a pain to debug, but the alert(''); function will show a popup and can be quite useful to determine if your code and/or logic is progressing as you would expect.
1 Attachment(s)
Re: Open web page according to day
Thank you so much!:cool:
Even I asked on the wrong forum, I found the correct person... Now it works perfect...
Just a Note: window.navigate("url") doesn't works on the last versions of Firefox nor Chrome (just on IExplorer); your suggested method window.location "url"; works on both & IExplorer too.
Thanks again!. At the end it was:
<script type="text/javascript">
var current= new Date()
var day=current.getDay()
if (day==0)
window.location = "http://tialele.weebly.com/platillos.html";
if (day==1)
window.location = "http://tialele.weebly.com/lunes.html";
if (day==2)
window.location = "http://tialele.weebly.com/martes.html";
if (day==3)
window.location = "http://tialele.weebly.com/miercoles.html";
if (day==4)
window.location = "http://tialele.weebly.com/jueves.html";
if (day==5)
window.location = "http://tialele.weebly.com/viernes.html";
if (day==6)
window.location = "http://tialele.weebly.com/platillos.html";
</script>