Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Blobby-Boi committed Oct 8, 2023
1 parent 60a8ff3 commit 7221809
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
// Get the URL from the user.
const thing = document.getElementById("thing");

// Check if the URL already includes a protocol.
if (thing.value.startsWith("https://") || thing.value.startsWith("http://")) {
// Open the URL directly.
window.location.href = thing.value;
} else {
// Prepend the HTTPS protocol to the URL and open it.
window.location.href = "https://" + thing.value;
}
// Submit the URL when the user clicks the button.
document.getElementById("submit").addEventListener("click", function() {
// Check if the URL already includes a protocol.
if (thing.value.startsWith("https://") || thing.value.startsWith("http://")) {
// Open the URL directly.
window.location.href = thing.value;
} else {
// Prepend the HTTPS protocol to the URL and open it.
window.location.href = "https://" + thing.value;
}
});
</script>
</head>
<body>
Expand Down

0 comments on commit 7221809

Please sign in to comment.