Upon selecting the correct prompt, it fails to respond when I press enter

I attempted to use a multi-search script that I found on a website. I followed the instructions given and made the necessary changes. After saving the file as an HTML document, I opened it in Chrome. However, when I type in a word and hit enter, nothing happens. As someone with limited knowledge about computers, I am unsure of where to even start troubleshooting.

Furthermore, I have tested the script on Explorer and Firefox, but it does not work on those browsers either.

<!DOCTYPE html>
<html>
<head>
</head>
<body style=”background-color:grey”>

<p>Please input the German word you would like to search for below and press enter.</p>
<input type=”text” id=”boxu” autofocus>

<script>
document.getElementById(“boxu”).onkeydown = function(e) {searchy(e)};
function searchy(e)
{
if (e.which == 13)
{
var q = document.getElementById(“boxu”).value;
window.open(“http://translate.google.com/translate?hl=en&sl=de&tl=en&u=http%3A%2F%2Fwww.google.de%2Fsearch%3Fq%3D” + q + “%26num%3D10%26hl%3Dde%26tbo%3Dd%26site%3Dimghp%26tbm%3Disch%26sout%3D1%26biw%3D1075%26bih%3D696”);
window.open(“http://www.forvo.com/word/” + q + “/#de”);
window.open(“https://de.wiktionary.org/wiki/” + q);
document.getElementById(“boxu”).value = “”;
}
}
</script>
</body>
</html>

Answer №1

Check out the code snippet below to solve your issue: Insert the onkeydown function within the textbox input element. Despite being included in the script, the function is not being called. Also, ensure that you are using the correct quotations as per the comment's suggestion.

<!DOCTYPE html>
<html>
<head>
</head>
<body style="background-color:grey">

<p>Enter the German word you wish to search for. Type it in the box and hit enter.</p>
<input type="text" id="boxu" autofocus onkeydown="searchy(event)">

<script>

function searchy(e)
{
   console.log(e)
if (e.keyCode == 13)
{
   console.log("a");
var q = document.getElementById("boxu").value;
window.open("http://translate.google.com/translate?hl=en&sl=de&tl=en&u=http%3A%2F%2Fwww.google.de%2Fsearch%3Fq%3D" + q + "%26num%3D10%26hl%3Dde%26tbo%3Dd%26site%3Dimghp%26tbm%3Disch%26sout%3D1%26biw%3D1075%26bih%3D696");
window.open("http://www.forvo.com/word/" + q + "/#de");
window.open("https://de.wiktionary.org/wiki/" + q);
document.getElementById("boxu").value = "";
}
}
</script>
</body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using nodeMCU along with ajax means that instead of refreshing just a single element, the entire web page

I'm in need of assistance with reloading two elements on my webpage. I am working with small electronics and the NodeMCU as its brain. I require two outputs (connected to relays) and two inputs. For the inputs, I would like them to update periodicall ...

Unable to modify document value in MongoDB using Node.js

Currently, I am attempting to fetch the value of a field form that is being sent to a subroute and utilize it to update a database collection. My ability to retrieve the form value and manipulate it is working fine; however, I encounter an issue when I sol ...

Absence of reactions visible

I am eagerly awaiting responses to a message. The member begins typing, then the bot responds, and the user is expected to react to the bot's message. I attempted to execute this code, however, when it reached the console.log("OK"), nothing happened. ...

Tips for generating an HTML template as a string using jQuery

I have developed a dynamic modal using plain JavaScript, triggered by a button click. This modal is controlled based on the attributes `data-open-hours` and `data-closed-hours` in the HTML. If you take a look at my demo, you will notice an issue. Let me e ...

Troubleshooting: How can I ensure my custom scrollbar updates when jQuery niceselect expands?

I am currently utilizing the jquery plugins mCustomScrollbar and niceselect. However, I have encountered an issue when expanding the niceselect dropdown by clicking on it - the mCustomScrollbar does not update accordingly. I suspect this is due to the abso ...

Trouble arises when attempting to use JavaScript, JSP, and JSON in conjunction with

I am in the process of creating a client-server application where I send a request from the client to the server using a JSON object for registration. However, despite receiving a JSON response with an "OK" field as expected, the client keeps triggering th ...

Strategies for modifying state in reactjs

My chat application, built using reactjs, nodejs, and mongodb, is experiencing an issue. Although I am storing data in mongodb and adding single messages to the 'messages' array, the chat app does not display these messages. It seems that even be ...

transferring information to a different application module (or page) through a double-click feature in AngularJS

Within my angularjs application, I am faced with a challenge involving two pages. The first page retrieves data from a database and displays it in a table. Upon double-clicking on a row, the user is directed to another page where more detailed informatio ...

The jQuery hide and show functions lack precision and are too indiscriminate, requiring a more targeted approach

I am designing a unique contact card that captures a user's name and description from an <input> field and appends the input information into a <div> element. This is the flow I am aiming for... User inputs their first and last name alo ...

Is there a way to detect the completion of the fadeout animation before calling a function?

I am trying to create a toast message using jQuery. When the "show" class is appended to the div, I want the toast message to fade in and then fade out after a few seconds. Once the fade-out animation is complete, I need to remove the "show" class. This ...

Navigating JSON data with unexpected fields in Typescript and React.js

Looking to parse a JSON string with random fields in Typescript, without prior knowledge of the field types. I want to convert the JSON string into an object with default field types, such as strings. The current parsing method is: let values = JSON.parse ...

A mysterious JavaScript snippet that automatically scrolls down when the webpage is loaded

Recently, I encountered an issue with a mysterious JavaScript script that automatically scrolls down when entering the page (I suspect it's JavaScript). I've tried to investigate using Firebug, examining the code, deleting scripts, and even remov ...

Stopping XSS Attacks in Express.js by Disabling Script Execution from POST Requests

Just starting to learn ExpressJs. I have a query regarding executing posted javascript app.get('/nothing/:code', function(req, res) { var code = req.params.code; res.send(code) }); When I POST a javascript tag, it ends up getting execut ...

displaying a div as a pop-up within an ASP.NET MVC 4 web application

One aspect of my asp.net MVC 4 application involves a partial view structured like so: <form class="qty-add" action="#" method="POST"> <label>Qty:</label> <div class="inp-controller"> <a href="#" c ...

The HTML image is not updating, the function does not appear to be triggering

My attempt to add a source to an image using JavaScript and some jQuery code I found online isn't working as expected: <html> <head> <script src = "http://www.example.com/images/"> var count=1; var initnumber=100 ...

Real-time Feedback: Providing live updates to users about the current connection status

My task requires pulling data from multiple datasources which can be time-consuming. To enhance user experience, I want to provide real-time information about the progress by displaying messages like "Currently retrieving data from table1" and "Now fetchin ...

What's the reason why Angular stops flickering with the use of "/" in href?

Recently, I've come across a peculiar issue in one of my web applications while using Angular's routeProvider as a template engine. The app functions properly, but the behavior seems inexplicable to me. The problem arises during page transitions ...

Ensure the detection of 404 error status using jQuery

My current approach involves using this code snippet to retrieve data from Twitter through its API: $.ajax({ url : apiUrl, cache : false, crossDomain: true, dataType: "jsonp", success : f ...

What steps can I take to make my search button work with this JavaScript code?

I am struggling with integrating my custom search bar with a JavaScript code to make it functional. Here is the code snippet for the Search Button: document.getElementById('searchform').onsubmit = function() { window.location = 'http:/ ...

Trouble with the div element's change event

Hey there! I'm having trouble with this jQuery code that is supposed to fade in or fade out a div based on its contents. Here is the HTML code: <div class="mainContentWrapper"> sample text </div> And here is the CSS code: div.main ...