JavaScript passing coordinates from one function to another -
i having issues passing 2 coordinates 1 function another. don't know javascript, seems correct. please let me know error?
<head> <script> var zoom = 12; // 18 mobile phones because geolocation more accurate function init() { // don't bother if web browser doesn't support cross-document messaging if (window.postmessage) { if (navigator && navigator.geolocation) { try { navigator.geolocation.getcurrentposition(function(ppos) { send(ppos.coords.latitude, ppos.coords.longitude); }, function() {}); } catch (e) {} } else if (google && google.gears) { // relevant if targeting mobile phones (some of may have google gears) try { var geoloc = google.gears.factory.create("beta.geolocation"); geoloc.getcurrentposition(function(ppos) { send(ppos.latitude, ppos.longitude); }, function() {}); } catch (e) {} } } } function send(plat, plng) { var myiframe = document.getelementbyid("myiframe").contentwindow; // third parameter, zoom, optional myiframe.postmessage(plat + "," + plng + "," + zoom, "http://www.qib.la"); } window.onload=init; </script> </head> <body> <iframe id="myiframe" src="http://www.qib.la/embed/" width="400" height="400"> check prayer direction towards ka'ba in makkah @ <a href="http://www.qib.la/">qibla direction</a>. </iframe> <script type="text/javascript" src="http://praytimes.org/code/v2/js/praytimes.js"></script> <br> <p align="center">waterloo, on, canada<p> <div align="center" id="table"></div> <script type="text/javascript"> var date = new date(); // today var times = praytimes.gettimes(date, plat + "," + plng, -5); var list = ['fajr', 'sunrise', 'dhuhr', 'asr', 'maghrib', 'isha', 'midnight']; var html = '<table id="timetable">'; html += '<tr><th colspan="2">'+ date.tolocaledatestring()+ '</th></tr>'; for(var in list) { html += '<tr><td>'+ list[i]+ '</td>'; html += '<td>'+ times[list[i].tolowercase()]+ '</td></tr>'; } html += '</table>'; document.getelementbyid('table').innerhtml = html; </script> </body>
is possible return value asynchronous function? how use callback here?
you have syntax error in code:
var times = praytimes.gettimes(date, + b + ',' + c + , -5);
you have "+" , comma following it. i'm not sure intent code was, causing not run.
perhaps intended follow pattern of appending commas strings?
var times = praytimes.gettimes(date + ',' + b + ',' + c + ',' + -5);
or perhaps -5 meant separate argument?
var times = praytimes.gettimes(date, b + ',' + c, -5);
Comments
Post a Comment