- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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! ~(^_^)~
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And isn't there any way to fix the manual code?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
At this moment, there isn't any solutions to address this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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) ;

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page