473,804 Members | 3,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

event.keyCode=9 tab event doesn't work in FireFox

5 New Member
I am having trouble in calling tab event using my own function.
i call tab event using
event.keyCode = 9;
but firefox gives this error "Error: event is not defined".

What to do? plz help
May 17 '07 #1
10 35600
mrhoo
428 Contributor
To script event handling beyond IE you need to learn the DOM event model.
google it, or start here-
http://www.javascriptk it.com/domref/domevent.shtml
May 17 '07 #2
wgale025
23 New Member
in firefox you can try this:
[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function codeNum(e)
{
alert(e.keyCode );
}
</script>
</head>

<body>
<input type="text" onkeydown="code Num(event)"/>
</body>
</html>

[/HTML]
May 17 '07 #3
iam_clint
1,208 Recognized Expert Top Contributor
actually in firefox guys its charCode not keyCode... keyCode is IE specific.
May 17 '07 #4
pbmods
5,821 Recognized Expert Expert
First things, first, IE handles events differently from other browsers. In IE, 'event' works because Internet Explorer attaches the last event to the window. So when you type:

Expand|Select|Wrap|Line Numbers
  1. alert(event.keyCode);
  2.  
You're actually doing this (because 'with window' is assumed in JavaScript):
Expand|Select|Wrap|Line Numbers
  1. alert(window.event.keyCode);
  2.  
Instead, you want to use charCode:

Expand|Select|Wrap|Line Numbers
  1. function codeNum(e)
  2. {
  3.     if(!e)
  4.         e = window.event;
  5.     if(e.keyCode)
  6.         alert(e.keyCode);
  7.     else
  8.         alert(e.charCode);
  9. }
  10.  
May 17 '07 #5
nasir872
5 New Member
problem is in firefox event.keycode=9 returns error because event.keycode is a getter property. so i can't set tab event by assigning keycode= 9. is there any setter property of event.keycode by which we can assign any keycode to it?
May 25 '07 #6
pbmods
5,821 Recognized Expert Expert
is there any setter property of event.keycode by which we can assign any keycode to it?
Wait... you want to simulate a tab press?

Why not just use the focus method of the element you want to focus?
May 25 '07 #7
nasir872
5 New Member
dear pbmods, my application creates field names on run time so i can't pass the next field name or can't move focus to the field by using its name.
May 25 '07 #8
iam_clint
1,208 Recognized Expert Top Contributor
and why not? add names to your elements.
May 25 '07 #9
ComputerCE
1 New Member
and why not? add names to your elements.

IE provides "event.keyC ode" BUT

Mozilla provides "event.whic h"

Try this guys..
Jun 12 '07 #10

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

Similar topics

17
50292
by: Julia Briggs | last post by:
Are there any gotchas using if (event.keyCode==8)? I understand that to represent backspace, but it doesn't work. I am running Windows XP, using a typical keyboard - but no luck in detecting backspaces. Anyone have experiences with this?
1
20776
by: Perttu Pulkkinen | last post by:
I have different functions that receive window.event as parameter. Functions are used like this: <input type="text" id="x" onkeypress="return onKeyCurrencyCheck(ev, 'x')" onblur ="onBlurCurrencyCheck(event, 'x')""> Works very well with IE, but window.event and maybe window.event.keycode too seems to be missing form firefox. Is there a workaround for this?
6
18291
by: Justin Beasley | last post by:
Here is an answer for those who are looking for a keystroke evaluation script that works in Internet Explorer (IE 5.5, 6.0, 7.0 for PC--IE 4.0, 5.2 for Mac), Mozilla Firefox (Windows, Linux, and Apple Macintosh), Safari, Opera, and other off-brand web browsers. I have gone through many groups trying to find code that didn't break in Firefox--yet still worked in other browsers. Although many people give input on this topic, few are...
6
14909
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function keypress() {
3
2959
by: niconedz | last post by:
Hi The following code works fine in IE but not Firefox. It's a little script that zooms an image and resizes the window to fit. Can anybody tell me what's wrong? Thanks Nico == btw.. sorry for the long post ==
4
3408
by: bbp | last post by:
Hello, In an ASPX page I have a "Quit" button which make a simple redirect in code-behind. This button doesn't work no more since (I think) I moved from the framework 1.0 to 1.1 and it doesn't work only on IE! My ASPX page works in FireFox. If the button doesn't work it's because of validators (and it worked with the same code in v1.0).
7
3677
by: CharlesA | last post by:
Hi folks, first off, I'm using .Net framework 1.1 with ASP.net and C# I'm trying to do something very simple...but I can't figure it out I have an <asp:button runat="server"> in the test version of my app that is essentially a backdoor for changing the class of user inside the application on the fly....it has a textbox next to it you can type 1, 2, 3, 4 etc.. in the text box and when you click the button
1
4184
by: mathewda | last post by:
Hey, I'm having a problem that I consider kinda weird that is alluding me at the moment. I've wrote some code that will set up an XMLHttpRequest, it then makes a call to open and send and sets the onreadystatechange to another function of mine. onreadystatechange checks the ready state and if the ready state is 4 and the status is 200 it assigns to the innerHTML of a div. I also have some code that uses the attachEvent method so that all...
2
1519
bilibytes
by: bilibytes | last post by:
Hi, i have been creating an ajax aplication on my website and it worked as i expected it to work on Safari and Firefox, until i upgraded to Firefox 3. It doesn't work either on windows. the url is: http://www.whichselect.com I have created an event, that was triggered onmouseover the horizontal nav bar
0
9710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10340
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
10329
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
10085
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
9163
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
7626
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
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4304
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
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.