• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting properties of another file(ex.HTML)?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have a question.
I want in one HTML page(first.html) to display some properties, for example date of last modification or file size of another file(second.html)

With document.lastModified and document.fileSize I can get properties of current-first.html file...but can I do that for second.html?
Maybe by giving path/filename of that second file...?
Lets say both files are in the same directory.

I have found some code that works for iframe, displaying properties of its content window. But I would like some general way of getting those other file properties, not just with iframes and their contents. Anyway, here's the mentioned code-original, i tried to change it to work my way, but getting null value when copying script to a <td> of a table:

<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" on_load=getLastMod() src="prices.html" style="display:none;">
</iframe>

</body>
</html>

Thanks in advance.
Marko
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

JavaScript has no provisions for general file operations; this is only possible because the window.document object has a lastModified property for a loaded page.

If the page needs those dates for other pages, and you don't want to go the route of using iframes, use a server-side language that can embed those dates somewhere within the HTML page or the JavaScript code.
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic