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
10 35600
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
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]
iam_clint 1,208
Recognized Expert Top Contributor
actually in firefox guys its charCode not keyCode... keyCode is IE specific.
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:
You're actually doing this (because 'with window' is assumed in JavaScript): -
alert(window.event.keyCode);
-
Instead, you want to use charCode: -
function codeNum(e)
-
{
-
if(!e)
-
e = window.event;
-
if(e.keyCode)
-
alert(e.keyCode);
-
else
-
alert(e.charCode);
-
}
-
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?
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?
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.
iam_clint 1,208
Recognized Expert Top Contributor
and why not? add names to your elements.
and why not? add names to your elements.
IE provides "event.keyC ode" BUT
Mozilla provides "event.whic h"
Try this guys..
Sign in to post your reply or Sign up for a free account.
Similar topics |
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?
|
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?
|
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...
|
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()
{
|
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 ==
| |
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).
|
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
|
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...
|
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
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |