// Copy some text in the clipboard
await navigator.clipboard.writeText("Text to copy");
// Read text inside the clipboard
const clipText = await navigator.clipboard.readText();
// Listen to the copy event
document.addEventListener("copy", async function () {
// ...
});
// Listen to the paste event
document.addEventListener("paste", async function () {
// ...
});
navigator.geolocation.getCurrentPosition(
function (positions) {
var coordinates = position.coordinates;
console.log("Your current position is:");
console.log(`Latitude : ${coordinates.latitude}`);
console.log(`Longitude: ${coordinates.longitude}`);
console.log(`More or less ${coordinates.accuracy} meters.`);
},
function (err) {
console.warn(`ERROR(${err.code}): ${err.message}`);
}
);
// Will call the first function each time the position of the device changes
const watchId = navigator.geolocation.watchPosition(
function (positions) {
var coordinates = position.coordinates;
console.log("Your current position is:");
console.log(`Latitude : ${coordinates.latitude}`);
console.log(`Longitude: ${coordinates.longitude}`);
console.log(`More or less ${coordinates.accuracy} meters.`);
},
function (err) {
console.warn(`ERROR(${err.code}): ${err.message}`);
}
);