Forum Moderators: open

Message Too Old, No Replies

Can Javascript Do This.

...refer to another Web page to update a bit of text?

         

myrrh

1:07 am on Dec 12, 2008 (gmt 0)

10+ Year Member



I have four pages that all need to have a date regularly updated with the same date. Is there javascript that I can put on the three "auxiliary" pages that will refer to the date on the "master" page so I need to alter the date only on the "master" page?

Or is SSI the only way to do this?

lavazza

1:40 am on Dec 12, 2008 (gmt 0)

10+ Year Member



It can be done with javascript

E.g.

Write a file like so

[pre]document.write('<p> '
+ ' Hello World '
+ ' <br>Today is the 45<sup>th<\/sup>th of Febvember '
+ ' <\/p> '
);[/pre]

SAVE AS

[pre]myDateMessage.js[/pre]
in a directory called
[pre]myJsFiles[/pre]

and then, in the body of each page include this:

[pre]<script type="text/javascript" src="myJsFiles/myDateMessage.js"></script>[/pre]

- - - - - - - - - - - - - - - - - - - - -

Alternatively, you could use php...

Write a file (using plain, regular HTML) like so

[pre]<p>
Hello World
<br>Today is the 53<sup>rd</sup>th of Jantober
</p>[/pre]

SAVE AS

[pre]myDateMessage.php[/pre]
in a directory called
[pre]myPhpFiles[/pre]

and then, in the body of each page include this:

[pre]<?php [i]include[/i] ("myPhpFiles/myDateMessage.php"); ?>[/pre]

myrrh

8:04 pm on Dec 12, 2008 (gmt 0)

10+ Year Member



Thank you, lavazza, I may do that. But is there a way I can have the javascript on three of the pages refer to the first page so I need only update the one page and not have to edit myDateMessage.js?

In other words, if I have pages A, B, C, and D, is there a way I can update page A and have pages B, C, and D reflect that update?

daveVk

5:59 am on Dec 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could have pages B, C and D read page A via Ajax extract the date etc. But that is slow and messy, lavazza offers good advice. Can the date be got from somewhere else like time file updated, start of month or whatever.

myrrh

9:40 pm on Dec 13, 2008 (gmt 0)

10+ Year Member



I guess I could have the date come from the date the file is updated, yes? I found a script to do that but I could not figure out how to make it display inline where I want it in the content. Could someone point me to a resource for a script that will do that? Thanks!