Is there a way to insert the current date on a web page in Xara?
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>
Gary W. Priester
gwpriester.com | eyetricks-3d-stereograms.com | eyeTricks on Facebook | eyeTricks on YouTube | eyeTricks on Instagram
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: JS-Today.xar.
Acorn
Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat
Or perhaps, the appearance of a website that is current to the day.Are you expecting visitors that don't know what day it is?
Gary W. Priester
gwpriester.com | eyetricks-3d-stereograms.com | eyeTricks on Facebook | eyeTricks on YouTube | eyeTricks on Instagram
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 W. Priester
gwpriester.com | eyetricks-3d-stereograms.com | eyeTricks on Facebook | eyeTricks on YouTube | eyeTricks on Instagram
Gary, if it displayed the date then the code detail is all there.
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
Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat
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
Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat
Bookmarks