I am struggling with getting my JavaScript code to display the time correctly on my HTML Lockscreen.
After looking at a few examples, I noticed that others are using document.getElementById() instead of document.write() and pushing it to a div.
I attempted two different methods. The first attempt can be found here: http://pastebin.com/RT4xcvPt
The issue with this method is that the time does not update unless I unlock my phone and then turn the screen off again. Upon waking up the phone, the time displays correctly. However, if I leave it idle for 5 minutes and check the lockscreen, the time remains unchanged.
In my second attempt, I added setInterval() to the code. Here is attempt 2: http://pastebin.com/LfSiUK31
Unfortunately, this method results in the screen going completely black after 2 seconds. The initial problem persists where the time does not refresh until I unlock and then wake the phone. After waking it up, the screen stays on for 2 seconds before turning black (I used background-color: #ffffff; in the examples, but on the phone it's set to background-color: #000000; which may explain why it turns solid black).
If I can figure out a reliable way to make it work and have the time refresh when unlocking the phone to view the lockscreen, I could style and position the text accordingly.
Any suggestions or assistance would be greatly appreciated.