Is there a way to insert the current date on a web page in Xara?
Printable View
Is there a way to insert the current date on a web page in Xara?
Hi Marc - Here's a link I came up with for a search on the above https://duckduckgo.com/?q=code+to+in...&t=ffsb&ia=web
I don't think there is a native way to do this in Xara.
One of the more savvy members might suggest how to apply this.Code:<script language="JavaScript">
<!--
date=Date()
document.write(date)
//-->
</script>
Here goes:
- Text Tool: Create a Text Column with "Today's Date" in any font, style or format.
- Text Tool: Add the following Names to the selected Text: htmlblocktext & today (separately).
- Select Tool: Select the text object and then Utilities > Web Properties > Placeholder > HTML Code Insertion > HTML code (body), add:
Code:<script>
document.getElementById("today").innerHTML = Date().substr(4, 11);
</script>
- Done.
Change the range of the substr parameters to extract more or less as you need; drop it altogether to get the full Date() value ... = Date();].
Example file: Attachment 125546.
Acorn
Or perhaps, the appearance of a website that is current to the day.Quote:
Are you expecting visitors that don't know what day it is?
Which side of GMT's date are you going to display? Whichever it is, half of the world will see the wrong date!
Acorn - The file you posted did not have any of the names, code you suggested added.
I think this works for what you have suggested.
Gary, if it displayed the date then the code detail is all there.
Attachment 125555Attachment 125556
Your file's code matches mine so either will do. You placed the JS in the Placeholder, mine's in the Page, so my descriptive mistake, which is benign.
Page is better if you intent to propagate lots of current date's around the page; the id "today" would need changing to htmlclass="today" and the JS 'document.getElementById("today").innerHTML = Date().substr(4, 11);' would need to become 'document.getElementsByClassName("today").innerHTML = Date().substr(4, 11);'. The JS is need in the Website HTML Code (head) if it is going to be on every page.
Acorn
Any GMT date is accurate if it displays the date & Time for any part of the world.
There are JS methods to convert raw Date() values [e.g., Tue Nov 12 2019 15:03:51 GMT+0000 (GMT Standard Time)] to local time...
I was simply demonstrating the structure of add JS code to an existing Xara Text Object and flexibly retaining its position and formatting without extra code.
Acorn