Skip to content

Instantly share code, notes, and snippets.

@kristianrl
Created November 12, 2015 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristianrl/da1f50d83ebbb384d715 to your computer and use it in GitHub Desktop.
Save kristianrl/da1f50d83ebbb384d715 to your computer and use it in GitHub Desktop.
Google search in new tab for each line in a textfield
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>New Google search for each line</title>
<script>
function searchgoogle () {
var searchlines = document.getElementById("searchfield").value;
searchlines = searchlines.split("\n");
for (var i = 0; i < searchlines.length; i++) {
document.getElementById("output").innerHTML += i + ": <a href=\"http://www.google.com/search?q=" + searchlines[i] + "&btnI=I\">"+ searchlines[i] +"</a><br />";
// SetTimeout?
window.open("https://www.google.com/search?q=" + searchlines[i] + "&btnI=I", i);
}
}
</script>
</head>
<body>
Paste the items you want to google in the list below, with one item per line.<br />
<textarea id="searchfield" style="height: 500px; width: 450px;"></textarea><br />
<button onclick="searchgoogle()">Search</button>
<div style="background-color: pink;" id="output"></div>
Note that this is <a href="http://stackoverflow.com/questions/16749907/window-open-behaviour-in-chrome-tabs-windows">not working on Google Chrome</a>.
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment