- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hello friends,
I'm making one small app, in which I created a function to show current time of device, calling it on body load, and using it in div. But problem is that once I open design (after writing code), <body onload="startTime()"> disappears, and time doesn't work, And if I go directly from code to emulator, time works perfectly.
Here is code of function:
function startTime() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); m = checkTime(m); s = checkTime(s); document.getElementById('horas_atuais').innerHTML = h+":"+m+":"+s; var t = setTimeout(function(){startTime()},500); } function checkTime(i) { if (i<10) {i = "0" + i}; // add zero in front of numbers < 10 return i; }
I'm starting this function when body loads :
<body onload="startTime()">
And showing it in div:
<div class="container" style="width: 100%; position: relative; height: auto; text-align: right;" data-appbuilder-object="container"> <div id="horas_atuais" class="text_item" data-appbuilder-object="text">Horas </div> </div>
Thanks! ~(^_^)~
コピーされたリンク
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
When using the Intel XDK App Designer (Design) tool, any manual edits to the source Code will be overwritten in the index.html by the tool. If you go to the Design panel from the Code panel then add a UI element, the code is regenerated removing all of the manual edits.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
And isn't there any way to fix the manual code?
Thanks!
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
At this moment, there isn't any solutions to address this issue.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Instead of inserting JavaScript into the html file, put it in a separate JS file and add an ID to the tag of interest. Then, in your JS code, use something like this to add your event handler:
var el ; el = document.getElementById("id_startTime") ; el.addEventListener("load", startTime, false) ;
