PDA

View Full Version : Putting Last Modified Date in footer with external js



lschena
07-28-2011, 02:39 PM
Hello,

I am fairly new to Javascript - so HELP!!!.

I have to make a template page with "Date Last Modified" on the bottom of the page and next to this date will be a name, copyright symbol and 2011.

The Javascript code has to be put in an external file.This is the code for the date I need to use:

This document was last modified on:
<script type="text/javascript">
document.write(document.lastModified);
</script>
(Then this?)Guys Name &nbsp&nbsp copyright symbol 2011

I am not sure what goes where - the src"" reference of the external file goes in the top of the body, I think, then how do I get the footer to display at bottom of page and do I write in the guys name and copyright/year part after the closing </script> that will be included in the external file??

The easier way for me would be better if there are various ways to do this. Any input would be greatly appreciated!

Jim

jscheuer1
07-28-2011, 04:30 PM
Put this and only this in the external script file:


document.write(document.lastModified);

Save it as lastmod.js and put it in the same folder as the page.

Change this:


<script type="text/javascript">
document.write(document.lastModified);
</script>
(Then this?)Guys Name &nbsp&nbsp copyright symbol 2011

to:


<script type="text/javascript" src="lastmod.js"></script>
(Then this?)Guys Name &nbsp&nbsp copyright symbol 2011

That's it. And other than changing the script, there's virtually no other way.

lschena
07-28-2011, 06:31 PM
Thanks so much for the help. I have it working however, how can I stick this content to bottom (or footer) of the page?

jscheuer1
07-28-2011, 07:21 PM
The same way you would anything else. It may be javascript, but it just outputs ordinary text.

So, say your footer was:


<div id="footer">
Some stuff Here
</div>

Now it can be:


<div id="footer">
Some stuff Here
<script type="text/javascript" src="lastmod.js"></script>
(Then this?)Guys Name &nbsp&nbsp copyright symbol 2011
</div>