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

Home Posts Topics Members FAQ

I would like to intercept all click events on my document

Hi,

I am beginner in JavaScript. I would like to intercept all click
events on my document. I use this function for that
document.onmous edown=click;. It works well. But I would like to
continue the execution code on a other button or anything else.
Example
1) Click anywhere intercept click->Execute the code in function click().
2) Click on a link…. intercept click -> Execute the code in function
click() ->Load the link(http://test.html)
3) Click on a button… intercept click-> Execute the code in function
click() ->Execute the code for the button(submit, or other javascript)
Thank a lot for your help…

function click() {
if (event.button== 1) {
alert(“Test event”)
//execute before….ex close all div
}
//Here continue code
}
Jul 23 '05 #1
1 4219
"zoltix" <ne********@lli .be> wrote in message
news:41******** **************@ news.skynet.be. ..
Hi,

I am beginner in JavaScript. I would like to intercept all click
events on my document. I use this function for that
document.onmous edown=click;. It works well. But I would like to
continue the execution code on a other button or anything else.
Example
1) Click anywhere intercept click->Execute the code in function click().
2) Click on a link…. intercept click -> Execute the code in function
click() ->Load the link(http://test.html)
3) Click on a button… intercept click-> Execute the code in function
click() ->Execute the code for the button(submit, or other javascript)
Thank a lot for your help…

function click() {
if (event.button== 1) {
alert(“Test event”)
//execute before….ex close all div
}
//Here continue code
}


Is this what you're looking for?

<html>
<head>
<title>clicked. htm</title>
<script type="text/javascript">
function clicked(what) {
alert(what);
}
</script>
</head>
<body onclick="clicke d(0)">
<a href="http://www.google.com/options/index.html?1" target="_blank"
onclick="return clicked(1)">Goo gle</a>
<br><br>
<form action="http://www.google.com/options/index.html?2" method="get"
target="_blank" >
<input type="button" value="Button" onclick="clicke d(2)">
<input type="submit" value="Submit" onclick="clicke d(3)">
</form>
</body>
</html>
Jul 23 '05 #2

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

Similar topics

13
9465
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to intercept the key so that I can do stuff on the server side to make the new window behave correctly? (We have a JSP-based webapp which stores state in the session. Now if two windows access (and modify!) the same session, then madness will result....
1
2251
by: Morten Overgaard | last post by:
Hi all Is it possible for a .Net app. to intercept the "open" action on files in a given directory. I want to intercept the "open" action and the perhaps direct the client ( the app. which is trying to open the file ) to another file - or stream another file back to the client in someway??? Any help is appreciated Regards Morten
18
6070
by: nutso fasst | last post by:
Hello. Is there a way to make an element 'transparent' to mouse activity, such that mouse events go to the underlying element? I have an absolutely-positioned image element with transparency that partly overlaps another element. I want mouse events on the overlapping image to go to the underlying element. Thanks, nf
9
8294
by: Charles Law | last post by:
I have asked a similar question to this before, but have not found a satisfactory answer yet, so I thought I would ask it in another way. KeyPreview, for a form, handily allows keys to be intercepted at form level, and pre-processed and/or filtered. In the absence of a MousePreview setting, is there a way to do the same thing for mouse movements and clicks? TIA Charles
0
1352
by: Elmar Jacobs | last post by:
hi guys, i have a c# CF model- view- controll application and the problem that i whant to handle the key and mouse events in the control class. the type of the control class is a normal class. the type of the view is a windows form and the control class is creating and destroying the view class. my problem is that the keys are going to the view class because it has the focus and it is from the type form. i tryed to deduce the control...
5
3181
by: Benny | last post by:
I have a ASP.NET webservice and it is configured to run in a web garden with multiple processes. Whan a process in the garden is launched, I want the process to create a background thread. When request are received by this instance of the garden process, a meessage is posted to the background thread to do its work. When the garden process is being down by IIS (due to a period of inactivity), I want to notify the background thread to...
4
6829
by: jobs | last post by:
the javascript: function ShowTooltip(L1in) { document.getElementById("L1").innerText=L1in; y = event.clientY + document.documentElement.scrollTop; var Popup= document.getElementById("Popup") Popup.style.display="block"; Popup.style.position="absolute"; Popup.style.left = 220;
3
4178
by: lookaround | last post by:
Hi everyone, I need some help... I call an external exe (a command-line tool) with Process.Start through this code: try { p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = ExePath;
0
9704
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
10558
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
10318
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...
0
10069
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
6844
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();...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
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
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2975
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.