Results 1 to 5 of 5

Thread: way of opening html page in a script

  1. #1
    Join Date
    Aug 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default way of opening html page in a script

    I have a date script that looks up the month and date and then will open js

    example

    Code:
    if ((daym==16)&&(month==8)) document.write("<a href=\"august/august_1.html\">August 1 </a>")
    if ((daym==26)&&(month==3)) document.write("<script src=\"jsfiles/26.js\"></script>")
    if ((daym==27)&&(month==3)) document.write("<script src=\"jsfiles/27.js\"></script>")
    if ((daym==28)&&(month==3)) document.write("<script src=\"jsfiles/28.js\"></script>")
    if ((daym==29)&&(month==3)) document.write("<script src=\"jsfiles/29.js\"></script>")
    if ((daym==30)&&(month==3)) document.write("<script src=\"jsfiles/30.js\"></script>")
    if ((daym==31)&&(month==3)) document.write("<script src=\"jsfiles/30.js\"></script>")

    what i need to do is on the date to open a html file


    i have writen in the past all the information in the html file into a js file, but it takes up a lot of time

    is there a way to have a document.LOAD("august_1.html"> when the date is reached

    example
    Code:
    if ((daym==16)&&(month==8)) document.load("august_16.html")
    if ((daym==17)&&(month==8)) document.load("august_17.html")
    if ((daym==18)&&(month==8)) document.load("august_18.html")

    any ideas on this????
    Last edited by keyboard; 08-16-2013 at 10:56 PM. Reason: Format: Code Tags [code][/code]

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,317
    Thanks
    30
    Thanked 136 Times in 131 Posts
    Blog Entries
    29

    Default

    You mean something like this?
    Code:
    <head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
    <script type="text/javascript">
    var daym=new Date().getDate(), month=new Date().getMonth()+1;
    function load_file_corresponding_to_date()
    {
    if(daym==16 && month==8){$('body').load("august_16.html")};
    if(daym==17 && month==8){$('body').load("august_17.html")};
    if(daym==18 && month==8){$('body').load("august_18.html")}
    }
    </script>
    </head>
    
    <body onload="load_file_corresponding_to_date()">

  3. #3
    Join Date
    Aug 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yes that is the idea, however the images do not load.

    I am not running this from a website


    All the text loads fine but no images

    is there a way without using:
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>

    this script????

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    Yes, but there's a lot of code involved to duplicate what jQuery can do in this regard. I'd actually recommend using a more recent version of jQuery, like 1.9.1.

    Once the page is live, users will have it (jQuery) cached, so it's not a big deal. So many sites use it that almost everyone already has it in their cache.

    The fact that the images aren't showing up is troublesome. Perhaps their paths are incorrect. Their paths must be correct for the location of the page that they're being imported to, not for the location of the page that they're being imported from.

    But if you're happy just replacing the page, you don't need to worry about any of that or jQuery:

    Code:
    <script type="text/javascript">
    var daym=new Date().getDate(), month=new Date().getMonth()+1;
    function load_file_corresponding_to_date()
    {
    if(daym==16 && month==8){window.location.replace("august_16.html");}
    if(daym==17 && month==8){window.location.replace("august_17.html");}
    if(daym==18 && month==8){window.location.replace("august_18.html");}
    }
    </script>
    Last edited by jscheuer1; 08-17-2013 at 08:19 PM. Reason: add code
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,317
    Thanks
    30
    Thanked 136 Times in 131 Posts
    Blog Entries
    29

    Default

    Yes, that's the way to do it if you don't want to use Jquery. Put:
    Code:
    if(daym==16 && month==8){window.location.replace("august_16.html")};
    etc., just as John suggested.

    As for the images, they should load if they do load when your august-files are accessed directly. What's the content of your jsfiles?

Similar Threads

  1. Replies: 3
    Last Post: 01-18-2013, 08:23 PM
  2. Replies: 2
    Last Post: 03-20-2009, 10:27 AM
  3. Replies: 9
    Last Post: 07-04-2007, 09:42 PM
  4. script works in html page but not in php page Cross Browser marquee II ?
    By leonidassavvides in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 06-17-2007, 12:17 PM
  5. Ajax Tab Content Script - Opening a specific tab on page load
    By chronoxg3 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 04-24-2007, 04:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •