Skip to content

Instantly share code, notes, and snippets.

@hsuan1117
Created July 5, 2023 01:19
Show Gist options
  • Save hsuan1117/4e7dfc6966857de073d1f4560721e023 to your computer and use it in GitHub Desktop.
Save hsuan1117/4e7dfc6966857de073d1f4560721e023 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>Hello</h1>
<input type="text" name="q" placeholder="搜尋字串"> <!-- q=xxxx -->
<button id="search">搜尋</button>
<script>
document.getElementById('search').addEventListener('click', ()=>{
let q = document.querySelector('input[name=q]').value
location.href = 'https://www.google.com/search?q=' + q
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment