Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

google search input javascript

(function(){
    var googleBox = document.getElementById("googleBox"),
        searchButton = document.getElementById("searchButton");

  searchButton.addEventListener("click", function(){
    var userInput = googleBox.value,
        regex_google = new RegExp('google(.*)');

    if(userInput.match(/^([w-]+)/)[1].toLowerCase() === "google"){ // matches the first word in the string, which should be 'google'

      window.open('https://www.google.com/search?q=' + userInput.match(regex_google)[1].trim());
    }
  });
})();
Comment

google search input javascript

function takeInput(e) {

    // enter === 13

    if(e.which != 13) {
        return false;
    }

    var question = this.value;

    appendOutput("<p><b>HUMAN : </b>" + question + "</p>", output);
    appendOutput("<p><b>CHATBOT : </b>" + processInput(question) + "</p>", output);
    appendOutput('<hr/>', output);

    this.focus();
    this.select();

    output.scrollByLines(100);
}

function processInput(question) {
    var answer = "I cannot answer this question";

    if (question.toUpperCase() == "GOOGLE ") {
        answer = "Here is what I found on Google:";
        window.open('https://www.google.com/search?q=');
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: count same product with price in angular 
Javascript :: node spawn stdout stderr 
Javascript :: how to draw and expression tree 
Javascript :: salesforce lightning call javascript every x seconds 
Javascript :: jquery 1.6 jgrid pagging ejemplo 
Javascript :: Javascript highest to lowest 
Javascript :: odata filter query error Property access can only be applied to a single value. 
Javascript :: You may need an appropriate loader to handle this file type when importing images 
Javascript :: how to move an array over one 
Javascript :: link the filename to the visible layer 
Javascript :: react birthday 
Javascript :: what regular express will match valid internation number 
Javascript :: isnumber javascript 
Javascript :: jquery click ony works once on dropdown 
Javascript :: this in js class method 
Javascript :: node base64 svg to png 
Javascript :: how to set particle js not hovering over contents 
Javascript :: limiting the length of dynamic text inside html element 
Javascript :: reversing string 
Javascript :: Dynamically Generated Table 
Javascript :: jq query online tutorial 
Javascript :: missing state 
Javascript :: build class component react 
Javascript :: array name in id fields 
Javascript :: Cache and return requests 
Javascript :: javascript loop through array of objects es6 
Javascript :: closing all open files vscode 
Javascript :: simple promise 
Javascript :: how to send email 
Javascript :: service erstellen angular 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =