Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Last Modified Date From Different File (Help Please)

    Hi, I have main html page called "ana.html" which seldomly updated and another page "yeniler.html" that showing latest added articles and often updated. What I want is, whenever "yeniler.html" modified the javascript in "ana.html" shows "Latest Update Date: xx.xx.xxxx".

    As you can see I don't want to show file modified date of "ana" in "ana" like so many scripts offer on the web , but in page "ana" modified date of "yeniler"

    I also want the date format like 8.18.2008 (without hour, minute, and name of the month)

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    I think you will need a server-side script or AJAX for this.

    Or possibly yeniler writes a cookie containing the last update which ana can read (if ana is in the same domain).

  • #3
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    My server supports php but can I add php inside of my main html page?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Quote Originally Posted by tunayx View Post
    My server supports php but can I add php inside of my main html page?
    Yes, of course.

    Code:
    <?php
    
    // Change to the name of the file
    $last_modified = filemtime("thisfile.php");
    
    // Display the results
    // eg. Last modified Monday, 27th October, 2003 @ 02:59pm
    print "Last modified " . date("l, dS F, Y @ h:ia", $last_modified);
    
    ?>
    You could also try this:-
    Code:
    <script type= "text/javascript">
      myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
      file = myActiveXObject.GetFile("c:\\test.txt");
      alert(file.DateLastModified);
    </script>
    Last edited by Philip M; 08-18-2008 at 06:33 PM. Reason: Add code tags

  • #5
    Banned
    Join Date
    May 2005
    Location
    Midwest, U.S.
    Posts
    118
    Thanks
    1
    Thanked 26 Times in 23 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Any Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
    
    	function init(){
    
    		var modifiedStr = window.frames['currentArticles'].document.lastModified;		
    		modifiedStr = modifiedStr.replace(/\//g,".").substring(0,11);
    		document.getElementById('updateMsg').innerHTML = "Last modified on: " + modifiedStr;
    	}
    
    	onload = init;
    
    </script>
    <style type="text/css">
    
    	 body {background-color: #eae3c6; margin-top: 60px;}
    	 iframe {display: none;}
    	#updateMsg {font-family: arial; font-size: 14pt; color: blue; background-color: #f0fff0; padding: 3px; width: 350px; text-align: center; margin-left: auto; margin-right: auto;}
    	
    </style>
    </head>
    	<body>
    		<iframe name="currentArticles" src="./yeniler.html"></iframe>
    		<div id="updateMsg" class="updateMsg"></div>
    	</body>
    </html>

  • #6
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Phillip: javascript gives error and didn't work for me. Php works fine as standalone but how can I insert it to a layer to position it on my html, using frontpage?

    Cranford: Your worked standalone page but same trouble how can I insert it to a layer so I can position it on my html using frontpage?

  • #7
    Banned
    Join Date
    May 2005
    Location
    Midwest, U.S.
    Posts
    118
    Thanks
    1
    Thanked 26 Times in 23 Posts
    The info is already in a DIV. Use CSS to position the DIV.

    I set the DIV's class to #updateMsg

    Include in that class, positioning info, and delete the margin settings

    e.g.: position-top: 300px; position-left: 50px;

    #updateMsg {font-family: arial; font-size: 14pt; color: blue; background-color: #f0fff0; padding: 3px; width: 350px; text-align: center; position-top: 300px; position-left: 50px;}

  • #8
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Now another trouble, updated date (Cranford your code) stayed behind the picture (I want put it to right below on my main picture. I also can't replace #updateMsg, get script errors. I've sent my whole page, I have text "Put Date Here" can you place date there.

    Text too big to add the reply.

    http://rapidshare.com/files/138289204/ana.txt.html

  • #9
    Banned
    Join Date
    May 2005
    Location
    Midwest, U.S.
    Posts
    118
    Thanks
    1
    Thanked 26 Times in 23 Posts
    Post your question in the CSS forum. I never look at links, and I don't have time to customize the code for you.

  • #10
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Admin can delete this thread then, thanks.

  • #11
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,460
    Thanks
    11
    Thanked 600 Times in 580 Posts
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #12
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I found a solution from another site, if anybody needs here:


    <html>
    <head>
    <title>Last Modified</title>
    <script type="text/javascript">
    function getLastMod(){
    var myFrm = document.getElementById('myIframe');
    var lastModif = new Date(myFrm.contentWindow.document.lastModified);
    document.getElementById('LastModified').innerHTML = "Prices correct as at: " + lastModif.toLocaleString();
    }
    </script>
    </head>
    <body>
    <span id="LastModified"></span>

    <iframe id="myIframe" onload="getLastMod()" src="prices.txt" style="display:none;">
    </iframe>

    </body>
    </html>

  • #13
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Anybody an idea how to thange the output of this script into for example 25-12-2007
    I dont know anything about Java.
    Thanks.

    Quote Originally Posted by tunayx View Post
    I found a solution from another site, if anybody needs here:


    <html>
    <head>
    <title>Last Modified</title>
    <script type="text/javascript">
    function getLastMod(){
    var myFrm = document.getElementById('myIframe');
    var lastModif = new Date(myFrm.contentWindow.document.lastModified);
    document.getElementById('LastModified').innerHTML = "Prices correct as at: " + lastModif.toLocaleString();
    }
    </script>
    </head>
    <body>
    <span id="LastModified"></span>

    <iframe id="myIframe" onload="getLastMod()" src="prices.txt" style="display:none;">
    </iframe>

    </body>
    </html>

  • #14
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Be aware that Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

    Code:
    <html>
    <head>
    <title>Last Modified</title>
    <script type="text/javascript">
    function getLastMod(){
    var myFrm = document.getElementById('myIframe');
    var lastModif = new Date(myFrm.contentWindow.document.lastModified);
    var yr = lastModif.getYear();
    var mm = lastModif.getMonth()+1;
    if (mm <10) {mm = '0'+ mm}
    var dt = lastModif.getDate();
    if (dt <10) {dt = '0' + dt}
    var lmDate = dt +"-" + mm + "-" + yr;
    document.getElementById('LastModified').innerHTML = "Prices correct as at: " + lmDate;
    }
    </script>
    </head>
    <body>
    <span id="LastModified"></span>
    
    <iframe id="myIframe" onload="getLastMod()" src="prices.txt" style="display:none;">
    </iframe>
    
    </body>
    </html>

    Wednesday, the ladies Liturgy society will meet. Mrs. Jones will sing "Put me in my little bed" accompanied by the pastor. - Church bulletin.

  • Users who have thanked Philip M for this post:

    janbastiaanssen (09-11-2008)

  • #15
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks again Philip.

    When I try to call this function several times on one page only the first one gives result. Any idea why ??

    <html>
    <head>
    <title>Last Modified</title>
    <script type="text/javascript">

    <!-- tbv datum update
    function getLastMod()
    {
    var myFrm = document.getElementById('myIframe');
    var lastModif = new Date(myFrm.contentWindow.document.lastModified);
    var yr = lastModif.getYear();
    if (yr < 2000) {yr=yr+1900}
    var mm = lastModif.getMonth()+1;
    if (mm <10) {mm = '0'+ mm}
    var dt = lastModif.getDate();
    if (dt <10) {dt = '0' + dt}
    var lmDate = dt + "-" + mm + "-" + yr;
    document.getElementById('LastModified').innerHTML = " Update: " + lmDate;
    }
    </script>
    </head>
    <body>
    <span id="LastModified"></span>
    <iframe id="myIframe" onload="getLastMod()" src="van gastel.html" style="display:none;">
    </iframe>
    <br>
    <br>
    <span id="LastModified"></span>
    <iframe id="myIframe" onload="getLastMod()" src="ermen.html" style="display:none;">
    </iframe>
    <br>
    <br>
    <span id="LastModified"></span>
    <iframe id="myIframe" onload="getLastMod()" src="bastiaanssen.html" style="display:none;">
    </iframe>
    </body>
    </html>


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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