Write a site that sends to a random page of Ukrainian Wikipedia
- User
Write a site that sends to a random page of Ukrainian Wikipedia
- Assistant
Write a site that sends to a random page of Ukrainian Wikipedia
Certainly! You can create a simple website that automatically redirects visitors to a random page on the Ukrainian Wikipedia. Below are various methods to achieve this using HTML and JavaScript. You can choose the one that best fits your needs.
This method uses the <meta> tag to refresh the page and redirect the user to the desired URL immediately.
<!DOCTYPE html>
<html lang="uk">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=https://uk.wikipedia.org/wiki/Special:Random">
<title>Перехід до випадкової сторінки Вікіпедії українською...</title>
</head>
<body>
<p>Якщо ви не були автоматично перенаправлені, будь ласка, <a href="https://uk.wikipedia.org/wiki/Special:Random">натисніть тут</a>.</p>
</body>
</html>
<meta http-equiv="refresh" ...> tag tells the browser to navigate to the specified URL after the given time (0 seconds in this case).<body> provides a fallback in case the automatic redirection doesn't work.Using JavaScript provides more flexibility and control over the redirection process.
<!DOCTYPE html>
<html lang="uk">
<head>
<meta charset="UTF-8">
<title>Перехід до випадкової сторінки Вікіпедії українською...</title>
<script type="text/javascript">
// Redirect immediately
window.location.href = "https://uk.wikipedia.org/wiki/Special:Random";
// Alternatively, redirect after a delay (e.g., 2 seconds)
/*
setTimeout(function(){
window.location.href = "https://uk.wikipedia.org/wiki/Special:Random";
}, 2000);
*/
</script>
</head>
<body>
<p>Перехід до випадкової сторінки Вікіпедії українською...</p>
<p>Якщо ви не були автоматично перенаправлені, будь ласка, <a href="https://uk.wikipedia.org/wiki/Special:Random">натисніть тут</a>.</p>
</body>
</html>
window.location.href in JavaScript changes the current page to the specified URL immediately.setTimeout function if you prefer a delayed redirection.If your web server supports PHP, you can perform the redirection on the server side. This method is generally faster because it doesn't require the browser to load an HTML page first.
<?php
header("Location: https://uk.wikipedia.org/wiki/Special:Random");
exit();
?>
header() function sends a raw HTTP header to redirect the browser to the specified URL.exit() function ensures that no further code is executed after the redirection.Save this code in a file with a .php extension (e.g., index.php) and upload it to your server.
Create the File:
index.html or index.php).Customize (Optional):
Upload to Your Web Server:
Access Your Site:
https://yourdomain.com/) to test the redirection.Add a Loading Spinner: To improve user experience, especially if there's a delay before redirection, you can add a loading spinner.
Handle Errors Gracefully: Provide meaningful messages if the redirection fails.
Analytics Tracking: If you want to track how many users are using your redirection service, consider integrating analytics tools.
<!DOCTYPE html>
<html lang="uk">
<head>
<meta charset="UTF-8">
<title>Перехід до випадкової сторінки Вікіпедії українською...</title>
<style>
/* Center the loader */
.loader {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border: 16px solid #f3f3f3; /* Light grey */
border-top: 16px solid #3498db; /* Blue */
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
body {
background-color: #ffffff;
text-align: center;
font-family: Arial, sans-serif;
}
</style>
<script type="text/javascript">
// Redirect after 3 seconds
setTimeout(function(){
window.location.href = "https://uk.wikipedia.org/wiki/Special:Random";
}, 3000);
</script>
</head>
<body>
<div class="loader"></div>
<p>Триває перехід до випадкової сторінки Вікіпедії українською...</p>
<p>Якщо ви не були автоматично перенаправлені, будь ласка, <a href="https://uk.wikipedia.org/wiki/Special:Random">натисніть тут</a>.</p>
</body>
</html>
This example adds a simple CSS spinner and delays the redirection by 3 seconds, providing a better user experience.
Feel free to choose the method that best suits your requirements. If you need further customization or assistance with deploying your website, feel free to ask!
Not yet included in a published release.