473,573 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question about captureEvents

Hi,

With this code, I thought that any 'click' with the mouse would be captured
on the window level and nothing would happen, but a click on the button
triggers nevertheless the function hit(). Why is it not directed to the
function IgnoreEvents instead of the function hit?
....
<script>
window.top.capt ureEvents(Event .CLICK)
window.top.oncl ick=IgnoreEvent s

function IgnoreEvents(e)
{ return false }

function hit()
{ alert('hit') }
</script>

INPUT TYPE="button" onClick="hit()"
....

Thanks for your explanation
Dave
Jul 20 '05 #1
6 13829


Dave wrote:
Hi,

With this code, I thought that any 'click' with the mouse would be captured
on the window level and nothing would happen, but a click on the button
triggers nevertheless the function hit(). Why is it not directed to the
function IgnoreEvents instead of the function hit?
...
<script>
window.top.capt ureEvents(Event .CLICK)
window.top.oncl ick=IgnoreEvent s

function IgnoreEvents(e)
{ return false }

function hit()
{ alert('hit') }
</script>

INPUT TYPE="button" onClick="hit()"
...

Thanks for your explanation


captureEvents is part of the NN4 event model, and with NN4 I am sure you
can click the button as much as you want, it doesn't fire its onclick
handler:

<html>
<head>
<title>NN4 captureEvents</title>
<script type="text/javascript">
if (document.layer s) {
window.captureE vents(Event.CLI CK);
window.onclick = function (evt) {
return false;
}
}
</script>
</head>
<body>
<form>
<input type="button" value="button"
onclick="alert( event.type);">
</form>
</body>
</html>

I guess you are trying with Netscape 6/7 or Mozilla which unfortunately
has window.captureE vents as a function in its browser object model but
this doesn't do anything.
If you want to capture events with Netscape 6/7 or Mozilla use
window.addEvent Listener('event name', eventHandler, true)
as in

<html>
<head>
<title>NN4 captureEvents</title>
<script type="text/javascript">
if (document.layer s) {
window.captureE vents(Event.CLI CK);
window.onclick = function (evt) {
return false;
}
}
else if (window.addEven tListener) {
window.addEvent Listener('click ',
function (evt) {
if (evt.stopPropag ation) {
evt.stopPropaga tion();
return false;
}
},
true
);
}
</script>
</head>
<body>
<form>
<input type="button" value="button"
onclick="alert( event.type);">
</form>
</body>
</html>

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Thanks again, it works with NN 7.
But i still can click on the menu and other buttons of the browser. Is it
not possible to make this impossible?

Dave
"Martin Honnen" <Ma***********@ t-online.de> schreef in bericht
news:3F******** ******@t-online.de...


Dave wrote:
Hi,

With this code, I thought that any 'click' with the mouse would be captured on the window level and nothing would happen, but a click on the button
triggers nevertheless the function hit(). Why is it not directed to the
function IgnoreEvents instead of the function hit?
...
<script>
window.top.capt ureEvents(Event .CLICK)
window.top.oncl ick=IgnoreEvent s

function IgnoreEvents(e)
{ return false }

function hit()
{ alert('hit') }
</script>

INPUT TYPE="button" onClick="hit()"
...

Thanks for your explanation


captureEvents is part of the NN4 event model, and with NN4 I am sure you
can click the button as much as you want, it doesn't fire its onclick
handler:

<html>
<head>
<title>NN4 captureEvents</title>
<script type="text/javascript">
if (document.layer s) {
window.captureE vents(Event.CLI CK);
window.onclick = function (evt) {
return false;
}
}
</script>
</head>
<body>
<form>
<input type="button" value="button"
onclick="alert( event.type);">
</form>
</body>
</html>

I guess you are trying with Netscape 6/7 or Mozilla which unfortunately
has window.captureE vents as a function in its browser object model but
this doesn't do anything.
If you want to capture events with Netscape 6/7 or Mozilla use
window.addEvent Listener('event name', eventHandler, true)
as in

<html>
<head>
<title>NN4 captureEvents</title>
<script type="text/javascript">
if (document.layer s) {
window.captureE vents(Event.CLI CK);
window.onclick = function (evt) {
return false;
}
}
else if (window.addEven tListener) {
window.addEvent Listener('click ',
function (evt) {
if (evt.stopPropag ation) {
evt.stopPropaga tion();
return false;
}
},
true
);
}
</script>
</head>
<body>
<form>
<input type="button" value="button"
onclick="alert( event.type);">
</form>
</body>
</html>

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3
"Dave" <no@dsfg.vb> writes:
But i still can click on the menu and other buttons of the browser. Is it
not possible to make this impossible?


Generally, no. I wouldn't want to use a browser where it is possible,
and most users would find it highly annoying anyway.
The safest is to just forget the idea.

Please don't top post.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
Look at those very similar scripts: with the first, using a window, every
click of the mouse (even menus and buttons) is blocked as long as the
created window is open. With the second script, using a button, it should be
the same as long as the value of the button is not 'changed', but it doesn't
work. I can click anywhere.
If you could tell me why, it would be great (both scripts running with NN
7). Thanks in advance.
Dave

script 1:

<INPUT TYPE="button" value="block everything" onclick="start( )">
<INPUT TYPE="button" VALUE="anything " onclick="myfunc tion()">
<SCRIPT>
var winModalWindow

function start()
{
window.top.capt ureEvents(Event .CLICK|Event.FO CUS)
window.top.oncl ick="return false"
window.top.onfo cus=HandleFocus
xx="left=500,to p=300,dependent =yes"
winModalWindow = window.open("wi n2.htm","",xx)
winModalWindow. focus()
}
function HandleFocus()
{
if (winModalWindow )
{
if (!winModalWindo w.closed)
{
winModalWindow. focus()
}
else
{
window.top.rele aseEvents (Event.CLICK|Ev ent.FOCUS)
window.top.oncl ick = ""
}
}
return false
}

function myfunction()
{
alert("ok")
}
</script>

script 2:

<INPUT id="bu" TYPE="button" VALUE="should block" onclick="start( )">
<INPUT TYPE="button" VALUE="anything " onclick="myfunc tion()">
<INPUT TYPE="button" VALUE="changed" onclick="change ()">

<SCRIPT>
var winModalWindow

function start()
{
window.top.capt ureEvents(Event .CLICK|Event.FO CUS)
window.top.oncl ick="return false"
window.top.onfo cus=HandleFocus
winModalWindow = document.getEle mentById("bu")
winModalWindow. focus()
}

function HandleFocus()
{
if (winModalWindow )
{
if (! (winModalWindow .value=="change d"))
winModalWindow. focus()
else
{
window.top.rele aseEvents (Event.CLICK|Ev ent.FOCUS)
window.top.oncl ick = ""
}
}
return false
}
function myfunction()
{
alert("ok")
}

function change()
{
document.getEle mentById("bu"). value="changed"
}
</script>
Jul 20 '05 #5
Look at my post just above yours and you will see that in the first script,
it's impossible to click at anything, included buttons and menus (with NN7).
My question was: why does the second script not work?

Dave
"Dom Leonard" <do************ *@senet.andthis .com.au> wrote in message
news:Y7******** *********@nnrp1 .ozemail.com.au ...
Dave wrote:
Thanks again, it works with NN 7.
But i still can click on the menu and other buttons of the browser. Is it not possible to make this impossible?

Dave

A thought is that capturing click events will not itself disable menus
and buttons driven by mousedown/mouseup instead of click events. If the
case, these would need separate listeneres/event capture.

A quick google suggests that Internet Explorer 6 does not support event
capture as per DOM2 recommendations - meaning it does not support
addEventListene r registration - but does have its own attachEvent and
detachEvent methods. As far as I can determine IE does not support event
capture at all and would need modifications to event handlers at the
HTML tag or DOM node object level to get around the limitation.

Cheers,
Dom

Jul 20 '05 #6
Thanks for your explanation
Jul 20 '05 #7

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

Similar topics

3
5015
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
2645
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask it differently. FOUR QUESTIONS: The background: I got three (3) files
6
2205
by: Vincent van Beveren | last post by:
Hey everyone, I have trouble capturing events in Netscape 7.1. I am building a WYSIWYG editor thingy which should both work in IE and NS 7. For this I use designMode='on'. However, it seems like as soon as I do that, it stops capturing events from that element. // // EditGUI is a simple WYSIWYG editor for chat
8
392
by: Brian Wilson | last post by:
Is there anything that can be added to this code to disable right click on images or hyperlinks to hide the status also? function hidestatus(){ window.status='Done' return true } if (document.layers) document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
3
3072
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table before rowID answID qryrow questionID datafield 1591 12 06e 06e 06e question 1593 12 06f 06f 06f question 1594 12 answer to the question 06f
5
1240
by: Rocky Moore | last post by:
Been a while since I looked into this and have forgotten how to make the ENTER default to a LinkButton and it does on a standard button. If I remember correctly it required javascript. Thanks -- Rocky Moore www.HintsAndTips.com / Share your tips - Earn rewards www.MyQuickPoll.com / 2004 Election poll ID #33
2
3364
by: harry | last post by:
Hi I am trying to add an event handler to the window so that If the user clicks the close window button, it creates a popup to tell the user it should use the log out button before closing window. When I try to this: window.captureEvents(Event.CLICK); I get a javascript error saying the "Event" is undefined. Here is how I use the code
10
3407
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a database or continue to process on to the next page. I am now trying to learn ASP to see if we can replace some of our applications that were written in...
10
3698
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server Error in '/QuickStartv20' Application. -------------------------------------------------------------------------------- Configuration Error...
0
7755
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...
0
7992
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. ...
0
8190
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...
0
8048
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...
0
5281
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...
0
3722
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...
0
3722
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2183
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
1
1284
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.