Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<html>
<body>
<input type="radio" id="google" name="image" onclick="googleImages();" checked/>
<label for="google">Google Images</label>
<input type="radio" id="unsplash" name="image" onclick="poly();"/>
<!-- Try add function removeURLQueryString() and see how bad is -->
<label for="unsplash">Poly</label>
<form id="form" method="GET" action="https://www.google.com/search?q=">
  <input id="input" type="text" name="q" value="" required>
  <input id="button"  type="submit" value="Search" onclick="this.form.target='_blank';">
  <input id="helper" type="hidden" name="tbm" value="isch">
</form>
  
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
  
</body>
</html>
 
var
  form = document.getElementById("form"),
  input = document.getElementById("input"),
  button = document.getElementById("button"),
  helper = document.getElementById("helper");
function googleImages() {
  form.action="https://www.google.com/search?q=";
  input.name="q";
  helper.name="tbm";
  helper.value="isch";
}
function poly() {
  form.action="https://poly.google.com/search/";
  input.name="";
  helper.name="";
  helper.value="";
}
// this is bad solution :( works for Poly, but changes the default form behavior and makes it impossible to do new searches on Google Images
function removeURLQueryString() {
    $("#button").click(function(event) {
    window.open(form.action + encodeURIComponent(input.value));
    event.preventDefault();
    event.stopImmediatePropagation();
    });
}
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers