472,783 Members | 981 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 software developers and data experts.

Javascript dynamically change onkeydown event?

I have this UserScript for Grease monkey. but I can't get the onleydown event to fire in FIREFOX only. I've looked everywhere!

Expand|Select|Wrap|Line Numbers
  1. // ==UserScript==
  2. // @name           iGoogle Suggest
  3. // @namespace      Devin Samarin
  4. // @description    This automatcally selects the top result for your query.
  5. // @include        *google.com/ig*
  6. // ==/UserScript==
  7. function makeRequest() {
  8.     GM_xmlhttpRequest({
  9.         method: 'GET',
  10.         url: 'http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&qu='+encodeURI(document.getElementById('q').value),
  11.         headers: {
  12.             'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
  13.         },
  14.         onload: function(responseDetails) {
  16.             var response = responseDetails.responseText;
  17.             document.getElementById('q').value = response.split('["')[2].split('"')[0];
  18.         }
  19.     });
  20. }
  21. var quer = document.getElementById('q');
  22. quer.onkeydown = "alert('asa');";
onKeyDown = function() { ... };

onkeydown = function() { ... };

onkeydown = "...";

onKeyDown = "...";

onKeyDown = makeRequest;

onkeydown = makeRequest;
Jul 11 '07 #1
1 5668
5,390 Expert Mod 4TB
hi ...

add the onkeydown-eventhandling into a call from the onload-handler of the documents body ... during load the page is not fully rendered and the node is not available to be retrieved ... when you try it onload ... then the entire dom is loaded and document.getElementById finds your node and it will work then ;)

kind regards
Jul 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: joebob | last post by:
The following script if run in Internet Explorer should display a thumbview of a webpage that you point it to. To test it, replace test.htm with a valid html file. The problem I'm having is that...
by: Rob | last post by:
I have a date text box (input type = text) in an ASP.NET/Javascript environment. I wanted to force the users to enter dates in a "__/__/____", "dd/mm/yyyy" or similar format. The textbox needs to...
by: Mark Reginald James | last post by:
Hi, I'm trying to use a keyboard event function to change what element gets the focus after tab is pressed in a particular element. Simple HTML that demonstrates the problem is below. When...
by: Dunc | last post by:
I've got a Web page written in C#, and when it runs and the user presses enter, it submits the first button on the form. As you'd expect. I want the system to redirect to a different page when a...
by: Alejandro Penate-Diaz | last post by:
Hi. I was handling key events nicely using some Javascript on my apps using something like this: this.txtUserName.Attributes.Add("onkeydown","if((event.which && event.which == 13)||(event.keyCode...
by: rockdale | last post by:
Hi, All I have a textbox for user to input SSN, I havea javascript to format what he input to SSN format, I also have a onChange postback function to retrieve other info based on the SSN. ...
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: ...
by: =?Utf-8?B?QWJoaQ==?= | last post by:
Hi All, i have 3 textboxes for area Code,phone number and Extention and each have MaskedEditExtender associated with it. i want that when the length of first text box reaches it's maxlength ,...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.