Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4873

Other programming languages • Re: [Solved] Any HTML + JavaScript wizards ?

$
0
0

Code:

       +  "<form id='sync' method='get'"                        \       +  "  action='{}='>".format(cwd)                         \       +  "  <button type ='submit'>Synchronise Time</button>"  \       +  "</form>"                                             \       +  "<script type='text/javascript'>"                     \       +  "var myform = document.getElementById('sync');"       \       +  "myform.onsubmit = function(){"                       \       +  "  d = new Date();"                                   \       +  "  document.getElementById('sync').action +="         \       +  "  '=' + d.valueOf();"                                \       +  "  myform.submit();"                                  \       +  "}"                                                   \       +  "</script>"
It seems it doesn't like something with a '?' in it being pushed into the 'action' but this works and I can handle it. It grows if one uses the browser back button but I'm sure I can figure out how to truncate it. Hence the pre-loaded '=' in the 'action' to help with that ...

Code:

    < GET /ram==1709225096168? HTTP/1.1      Synchronised time to '1709225096' - 2024-02-29 16:44:57    < GET /ram==1709225096168=1709225107832? HTTP/1.1      Synchronised time to '1709225107' - 2024-02-29 16:45:08    < GET /ram==1709225189269? HTTP/1.1      Synchronised time to '1709225189' - 2024-02-29 16:46:30
Browser sends milliseconds, I only need seconds.

Statistics: Posted by hippy — Thu Feb 29, 2024 4:51 pm



Viewing all articles
Browse latest Browse all 4873

Trending Articles