Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html>
<script src="https://www.w3schools.com/lib/w3.js "></script>
<body>
<div id="mydiv">
{{country}}
</div>
<script>
function foo(data) {
var myObject = { "country": "" + data.country.name + ""};
w3.displayObject("mydiv", myObject);
}
</script>
<script src="https://geoip.nekudo.com/api?callback=foo "></script>
</body>
</html>
// the second way to obtain country with w3.js
<!DOCTYPE html>
<html>
<script src="https://www.w3schools.com/lib/w3.js "></script>
<body>
<div id="id01">
<span>{{country_name}}</span>
</div>
<script>
w3.getHttpObject("http://freegeoip.net/json/", myFunction);
function myFunction(myObject) {
w3.displayObject("id01", myObject);
}
</script>
</body>
</html>
The most helpful W3.JS solutions
How to fill a dropdown using w3.js ?W3.JS Click to see more ... 1.1K 147