473,659 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript dynamically change onkeydown event?

eboyjr14
27 New Member
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 5744
gits
5,390 Recognized Expert Moderator Expert
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.getEle mentById 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
5877
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 I can't get onclick to fire on the rendered Thumbview object. What's strange is that onmouseover fires. Can anyone see a way? <html><head><title>test</title></head> <body onload="Init()">
1
14024
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 support normal copy/paste/delete format. There wasn't much on Google to help so (after a bit of toil) though I'd post my suggested solution here. No guarantees I'm afraid; just hope it helps somebody out there. Rob Here's the ASP source code:
22
26843
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 tab is pressed in the second input box I want focus to move to the first. It does this in IE, but not Mozilla 1.7.10. I can make it work in Mozilla by changing the event from onkeydown to onkeypress, but then it doesn't work in IE. Is there any
3
11783
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 user pressed enter from a second textbox. I've used the line of code in the Page_Load: SearchString.Attributes.Add("onKeyDown", "if (window.event) if (window.event.keyCode == 13) window.location='searchresults.asp?SearchString=' +...
6
1482
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 && event.keyCode == 13)){document.Form1.cmdLogin.click();return false;}else return true;"); that code rendered javascript to the client OK. Now that I upgraded to ASP.NET 2 Beta 2 it is rendering &amp;&amp; instead of &&, so clients are getting this...
2
2474
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. <asp:TextBox id="txtSSN" runat="server" AutoPostBack="true" onKeyDown="javascript:myJavaFunction"></asp:TextBox>
1
4941
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: http://munich.schwarz-interactive.de/autocomplete.aspx
0
1802
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 , focus will be set to next textbox automatically, means i want auto tabbed fields. for which i created java script function and associated it with OnKeyDown and OnKeyUp event of TextBox. but it's not working and when i remove the...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.