mirror of
https://github.com/driftywinds/driftywinds.github.io.git
synced 2025-12-19 11:03:32 +00:00
Initial commit
This commit is contained in:
16
js/index.js
Normal file
16
js/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const textField = document.querySelector("input");
|
||||
|
||||
textField.addEventListener("keypress", function (event) {
|
||||
// If the user presses the "Enter" key on the keyboard
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
|
||||
const url = textField.value;
|
||||
const urlRegex = /(https?:\/\/[^ ]*)/g;
|
||||
|
||||
if (!url.match(urlRegex))
|
||||
alert("Invalid URL.");
|
||||
else
|
||||
window.location.replace(`home.html?source=${url}`);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user