Running HTML5 in SC8

I have found from what I can see a very simple but valuable piece of code, unfortunately it is written in HTML5. Please can someone show me how to incorporate this code into my SC8 application, and also how I can get the long and lat values into their respective $long and $lat.

<!DOCTYPE html>
<html>
<body>

<p>Click the button to get your coordinates.</p>

<button onclick=“getLocation()”>Try It</button>

<p id=“demo”></p>

<script>
var x = document.getElementById(“demo”);

function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = “Geolocation is not supported by this browser.”;
}
}

function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>

You can just echo this code and will be shown (no needed title and son), but you can’t get client side variables as is. You have to pass by Ajax get/post

Giu -
Excuse my ignorance, but how would I echo the code?
Not quite sure why you mean by “title and son”?
Thanks
Larry

It’s not ignorance, are my fingers that looks like sausage.
If you want to show this piece of HTML on a field, and the field is called mymap, you can do something like this:

{mymap} = '
<p>Click the button to get your coordinates.</p>

<button onclick="getLocation()">Try It</button>

<p id="demo"></p>

<script>
var x = document.getElementById("demo");

function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosit ion);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}

function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
';

“echo” prints on screen what you write as param. If you write HTML, will be interpreted by the browser.

echo "<strong>This is a bold phrase</strong><br>";

In the same way, you can do it with JS instead HTML:

<script type="text/javascript">
var a = 1;
var b =2;
console.log(a+b);
</script> 

If you are on a blank app you can close PHP tag, output html and open it again.

PHP code....
?>

<!-- My html code -->
<strong>This is a bold phrase</strong><br>

<?php
My PHP code......

With “(no needed title and son),” what I tried to say from my mobile, is thath you don’t need all the headers tags and so on of HTML, because your SC app has it righ now. You can “output” HTML directly without tags <!DOCTYPE html> or <html> or <body>

Giuseppe!!! scriptcasers.com!!! Some royalty is in order here, can I send you my IBAN details?

lol, of course, try for it :slight_smile: