473,404 Members | 2,137 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,404 software developers and data experts.

Key events in invisible (by -Moz-Opacity) div (Mozilla)


Hello,

I cannot succeed in getting any key event on a div that's been set
invisible by the style's MozOpacity property under firefox. I'm using
this method so that I can capture the mouse events. Unfortunately, it
appears to do so only with mouse events, not key events.

Is there a better solution than the following? :
-----------------------------
<html>
<head>
<title>Event test..</title>
</head>
<body>

<div style="border: 3px solid green;">
<div id="foo">
</div>
</div>

<script>
var foo = document.getElementById ("foo");
foo.style.MozOpacity = 0;
foo.style.filter = "alpha(opacity=0)";
foo.style.backgroundColor = "red";
foo.style.width = "100%";
foo.style.height = "100px";
foo.onmouseover = function () {alert ('over');};
foo.onmouseout = function () {alert ('out');};
foo.onkeydown = function () {alert ('down');};
</script>
</body>
</html>
-----------------------------

As you'll notice, the mouse events will be fired, but not the key*
events.
Note: The code works under IE (I can reach the same effect as the
'MozOpacity' property by the 'filter' property)

Many thanks for any advice!

Best regards,
Arnaud
--
Arnaud DIEDEREN
Software Developer
IONIC Software
Rue de Wallonie, 18 - 4460 Grace-Hollogne - Belgium
Tel: +32.4.3640364 - Fax: +32.4.2534737
mailto:ad@ionicsoft.com
http://www.ionicsoft.com
Aug 1 '06 #1
2 3205
Arnaud Diederen (aundro) wrote:
Hello,

I cannot succeed in getting any key event on a div that's been
set invisible by the style's MozOpacity property under firefox. ...
<snip>
<html>
<head>
<title>Event test..</title>
</head>
<body>

<div style="border: 3px solid green;">
<div id="foo">
</div>
</div>

<script>
<snip>
</script>
</body>
</html>
-----------------------------

As you'll notice, the mouse events will be fired, but not the key*
events.
<snip>

There is nothing in this page that can have the keyboard focus so how
do you expect it to capture key events at all? But in any event, the
bubbling of key events would be from children to their parent, and so
on up, so only events originating with descendants of your invisible
DIV could be captured by it, and they would presumably be hidden
themselves.

Richard.

Aug 1 '06 #2


Arnaud Diederen (aundro) wrote:

I cannot succeed in getting any key event on a div that's been set
invisible by the style's MozOpacity property under firefox. I'm using
this method so that I can capture the mouse events. Unfortunately, it
appears to do so only with mouse events, not key events.
<div id="foo">
</div>
var foo = document.getElementById ("foo");
foo.style.MozOpacity = 0;
foo.onkeydown = function () {alert ('down');};
I don't think Mozilla fires any key events on div elements, whether you
apply any CSS opacity or not. You would need to have a child or
descendant element inside of the div that can receive key events (e.g.
<input type="text"or <textarea>), then that event might bubble up to
the div if someone types in a text control and can be handled in the
div's key event handler.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Joseph Misko | last post by:
I am on WinXP. The following page works perfectly in IE6. For Netscape 7.0, I have to move off of the image and then back on to get the fade to take effect, and with Mozilla (latest version) a...
11
by: Saqib Ali | last post by:
Please excuse me, this is a fairly involved question that will likely require you to save the file below to a file and open it in a browser. I use Mozilla 1.5, so the problem I describe below...
2
by: gene | last post by:
I have some javascript code that displays random images in random places on the page by making changes to the document's css. This works in Safari and IE, but I can't get it to work on Mozilla. ...
5
by: Harry Gould | last post by:
To all, I'm a newbie here, so please bear with me. I develop web pages for a company intranet where Internet Explorer 6 is the standard. Now I must develop a public internet website that is...
1
by: John Smith | last post by:
Can you tell me why Mozilla can't show some Javascript? example: function high(which2){ theobject=which2 highlighting=setInterval("highlightit(theobject)",50) } function low(which2){...
2
by: Peter Wright | last post by:
Hi all. Hopefully this should demonstrate the problem I'm having: http://flooble.net/~pete/focus-problem-demo/ (I'm testing it in Mozilla only, but I'm not sure if it's actually a...
4
by: Laurent Compere | last post by:
Hi all, I try to make a logo fade in. I wrote the code below that is simple and supposed to be compatible with IE6,Firefox and Netscape. It works pretty well under IE6 but under Firefox and...
7
by: Dayo | last post by:
Hello folks. Sorry if this seems a bit silly, I have no experience with this type of code. Here is a fading script for an Image Gallery I am looking to fix. It works with IE and Safari but not...
5
by: BibhuAshish | last post by:
Hi, I want to invisible one div. To invisible the <div> i have written like the following <div id="divid" style="display:none" > But the above code is working in IE, not in mozilla. What i...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
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,...

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.