473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Javascript dynamically change onkeydown event?

eboyjr14
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) {
  15.  
  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 5712
gits
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

4
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...
1
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...
22
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...
3
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...
6
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...
2
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. ...
1
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: ...
0
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 ,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.