Created
January 10, 2025 00:49
-
-
Save mjmsmith/292af3fdeba1e590760ed99f593a3cbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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