[JS] 提交到网址 url 搜索

更新 2020年5月1日 发布 2018年10月30日  WP & Websites
function ggl_dict() {
    var word = "https://www.google.com/search?q=Dictionary#dobs=" + $('#ggl-dict').val();
    window.open(word);
}

function enter2search() {
    if (event.keyCode == "13") {
        var word = "https://www.google.com/search?q=Dictionary#dobs=" + $('#ggl-dict').val();
        window.open(word);
    }
}
<div>
  <input id="ggl-dict" onKeyPress="enter2search()" type="text" placeholder="Search Google dictionary" autocomplete="off"/>
  <button type="button" onClick="ggl_dict()"><i class="fas fa-search"></i></button>
</div>