In the last exercise we rendered the social sharing buttons inside a webpage. However, the shared URL is defaulted to the URL of the page where the sharing action was performed. This exercise will show how to override this default behaviour and instead specify a custom URL for sharing, which is set as the homepage for Javaika. If you click on the Telegram social share button you should notice that the URL has changed accordingly.
<!DOCTYPE html> <!-- Copyright (c) 2026 by Javaika Technologies -->
<html lang = "en-AU"> <!-- Set the primary language to en-AU -->
<head>
<title>Share URL</title> <!-- Set the page title -->
<meta name = "robots" content = "noindex, follow">
</head>
<body>
<!-- Include the framework script tag -->
<script type = "module" src = "https://www.javaika.com/frame/web-share@main/api.js"></script>
<!-- Run the demo as an ES Module -->
<script type = "module">
// Initialize a shorter prefix for referencing.
const jws = window.javaika.webShare;
// Initialize the developer token endpoint.
jws.init({
tokenEndpoint: "https://www.javaika.com/pscript/jwt-access.php"
});
// Authenticate before using the framework.
jws.requestToken({
framework: "web_share" // Specify the framework for token issuance.
});
// Authenticate callback handler.
function onAuthenticate(event)
{
jws.refreshToken(); // Refresh the authentication token.
console.log('[Web Share] Authentication received callback:', event);
}
// Initialized callback handler.
function onInitialized(event)
{
// Set the share URL of the page on social media sites.
jws.setShareUrl("https://www.javaika.com");
console.log('[Web Share] Framework initialized callback:', event);
}
// Callback event after authenticate.
document.addEventListener
(
'javaika.webShare.authenticate', onAuthenticate
);
// Callback event after initialized.
document.addEventListener
(
'javaika.webShare.initialized', onInitialized
);
</script>
</body>
</html>