When is LONGRANGE javascript object available
Posted: Fri Mar 07, 2014 9:34 am
In the Programming LongRange With JavaScript document most of the APIs use the LONGRANGE object to access the custom APIs. I'm developing an app on an iPad 2 with iOS 7 and found that the LONGRANGE object is not immediately available when the webview loads and hence all my resulting code did not execute. I ran a test using the following code and found that LONGRANGE was only available after the 3 second timeout.
Is there a LONGRANGE.ready function or something similar I can use to check when the LONGRANGE object is ready? Is there some other setting I can set to make LONGRANGE load faster?
Thank you,
Siyaman
Code: Select all
<script type="text/javascript">
setTimeout(function(){
alert("After timeout " + typeof LONGRANGE);
},3000);
document.addEventListener("DOMContentLoaded", function(event) {
alert("OnDOMLoad " + typeof LONGRANGE);
});
alert("Rightaway " + typeof LONGRANGE);
// Output
// Rightaway undefined
// OnDOMLoad undefined
// After timeout [object]
</script>
Thank you,
Siyaman