Skip to content

Instantly share code, notes, and snippets.

@mjmsmith
Created January 10, 2025 00:49
Show Gist options
  • Save mjmsmith/292af3fdeba1e590760ed99f593a3cbd to your computer and use it in GitHub Desktop.
Save mjmsmith/292af3fdeba1e590760ed99f593a3cbd to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="text" id="urlInput" placeholder="Enter URL and press Enter" style="width: 300px; padding: 5px;">
<script>
const urlInput = document.getElementById('urlInput');
urlInput.addEventListener('keydown', function(event) {
if (event.key === 'Enter') {
event.preventDefault();
const url = urlInput.value.trim();
if (url) {
window.location.href = url;
} else {
alert('Please enter a valid URL.');
}
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment