Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Open web page according to day

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry 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:
    <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>
    Attached Files Attached Files


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,358
    Thanks
    182
    Thanked 834 Times in 777 Posts
    Blog Entries
    5

    Default 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
    if ( day == 0 )//note the ==
       //change location
    I've never used window.navigate, but you might achieve the same results with something like
    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.

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Re: Open web page according to day

    Thank you so much!

    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>
    Attached Files Attached Files

Similar Threads

  1. How do i have a jButton Open a URL?
    By dragon40226 in forum Java Theory & Questions
    Replies: 2
    Last Post: March 7th, 2011, 04:21 AM
  2. how to open a jsp in a new jsp
    By ajincoep in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: February 7th, 2011, 05:45 AM
  3. Open Text file
    By java_kiddy in forum File I/O & Other I/O Streams
    Replies: 7
    Last Post: October 5th, 2010, 03:52 AM
  4. Unable to open web service tester page
    By oneofthelions in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: December 13th, 2009, 06:20 PM
  5. Java program to open jsp page on client side instead of server side
    By khanshakil in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: July 8th, 2009, 07:26 AM

Tags for this Thread