“Google -Suche Eingabe JavaScript” Code-Antworten

Google -Suche Eingabe 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());
    }
  });
})();
Horrible Hamster

Google -Suche Eingabe 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=');
    }
}
Tense Tortoise

Ähnliche Antworten wie “Google -Suche Eingabe JavaScript”

Fragen ähnlich wie “Google -Suche Eingabe JavaScript”

Weitere verwandte Antworten zu “Google -Suche Eingabe JavaScript” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen