Đang chuẩn bị liên kết để tải về tài liệu:
Xây dựng ứng dụng cho Android với HTML, CSS và javascript - part 16

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Tham khảo tài liệu 'xây dựng ứng dụng cho android với html, css và javascript - part 16', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Next we ll rewrite the createEntry function that we first saw in Chapter 5 to use the geolocation feature of the phone to determine the current latitude and longitude. Replace the existing createEntry function in kilo.js with this function createEntry navigator.geolocation.getCurrentPosition 0 function position var latitude position.coords.latitude var longitude position.coords.longitude insertEntry latitude longitude function insertEntry return false O Begin the createEntry function. Q Call the getCurrentPosition function of the geolocation object and pass it two callback functions one for success and one for errors. This is the beginning of the success callback. Notice that it accepts a single parameter i.e. position . These two lines grab the latitude and longitude coordinates out of the position object. Pass the latitude and longitude coordinates into a function called insertEntry which we ll look at momentarily. This is the beginning of the error callback. O Because we re in the error callback this will only be called if geolocation fails for example if the user does not allow the application to access his location when prompted so call the insertEntry function without parameters. Return false to prevent the default navigation behavior of clicking the form s Submit button. Wondering where the SQL INSERT statement got to Let s take a look at the insertEntry function. This new function creates the entry in the database. Add the following to kilo.js function insertEntry latitude longitude var date sessionStorage.currentDate var calories calories .val var food food .val O db.transaction function transaction transaction.executeSql INSERT INTO entries date calories food latitude longitude VALUES date calories food latitude longitude Controlling the Phone with JavaScript 133 Download from www.eBookTM.com function refreshEntries checkBudget jQT.goBack errorHandler O The beginning of the insertEntry function allowing for latitude and longitude values to be passed in. .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.