473,835 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simulating a mouseclick

Is there a way in javascript to trigger the clicking of the left mouse
button.

Basically i have a floating div that is translucent (40% opacity) this
div covers the whole screen. when a user clicks on this div it
disappears. What i would like is if the mouse happens to be over a
link then that link should trigger.

I imagine i can do a long way which'll involve where is the mouse now,
what anchor is there, if its a link then set the location to this href.
But that seems like alot of work, can i not just simulate a click of
where the mouse is?

Hope people understand what i mean.

Andy

Nov 7 '06 #1
7 2485
VK

daveyand wrote:
Is there a way in javascript to trigger the clicking of the left mouse
button.

Basically i have a floating div that is translucent (40% opacity) this
div covers the whole screen. when a user clicks on this div it
disappears. What i would like is if the mouse happens to be over a
link then that link should trigger.

I imagine i can do a long way which'll involve where is the mouse now,
what anchor is there, if its a link then set the location to this href.
But that seems like alot of work, can i not just simulate a click of
where the mouse is?
IE has an absolutely wonderful method document.elemen tFromPoint(x,y) So
all you need to do is to use this method with the received click coords
(from clicking your DIV) and if there is a link at that point you are
using link's click() method on it.
<http://msdn.microsoft. com/workshop/author/dhtml/reference/methods/elementfrompoin t.asp>

Unfortunately no one other rival bothered so far to implement it, so
you have to code it manually somehow; see for instance:
<http://www.codingforum s.com/showthread.php? t=21674>

There can be more elegant and effective ways I don't know about.

Nov 7 '06 #2
Sym

VK wrote:
daveyand wrote:
Is there a way in javascript to trigger the clicking of the left mouse
button.

Basically i have a floating div that is translucent (40% opacity) this
div covers the whole screen. when a user clicks on this div it
disappears. What i would like is if the mouse happens to be over a
link then that link should trigger.

I imagine i can do a long way which'll involve where is the mouse now,
what anchor is there, if its a link then set the location to this href.
But that seems like alot of work, can i not just simulate a click of
where the mouse is?
Perhaps you can have a onMouseOver event assigned to each anchor which
then calls the appropriate script function.

rgds
Symeon.

Nov 7 '06 #3
Sadly i dont think the site will allow me to change the html itself.
(This div is a settings window that has been added on) So Sym sadly
wont be able to do that :(

VK i like your solution, i didnt know about the function you mentioned.
I love it, and wish, as you said, someone else had made something
similar.

Will look into seeing what i can do about that. So i guess i can
simply do something like

var oelement = document.elemen tFromPoint(iX, iY);
if(oelement == "A") {

location.src = oelement.src;

}

Or words to that effect?

Will look into making a FF and other browser version, or rather,
stealing the one you mentioned :)

Nov 7 '06 #4
VK

Sym wrote:
Perhaps you can have a onMouseOver event assigned to each anchor which
then calls the appropriate script function.
That will not work because with DIV hover the entire page all mouse
events will be sent to that DIV, not to elements below it.

Nov 7 '06 #5
ASM
daveyand a écrit :
Is there a way in javascript to trigger the clicking of the left mouse
button.

Basically i have a floating div that is translucent (40% opacity) this
div covers the whole screen. when a user clicks on this div it
disappears. What i would like is if the mouse happens to be over a
link then that link should trigger.

I imagine i can do a long way which'll involve where is the mouse now,
what anchor is there, if its a link then set the location to this href.
But that seems like alot of work, can i not just simulate a click of
where the mouse is?

Hope people understand what i mean.
Nope !

perhaps could you see stopPropagation and its brother for Ie ?

google -IE event propagation
Nov 7 '06 #6


On Nov 7, 11:53 am, "VK" <schools_r...@y ahoo.comwrote:
Sym wrote:
Perhaps you can have a onMouseOver event assigned to each anchor which
then calls the appropriate script function.That will not work because with DIV hover the entire page all mouse
events will be sent to that DIV, not to elements below it.
Good point :)

Nov 7 '06 #7
VK wrote:
Sym wrote:
Perhaps you can have a onMouseOver event assigned to each anchor which
then calls the appropriate script function.

That will not work because with DIV hover the entire page all mouse
events will be sent to that DIV, not to elements below it.
When the DIV is removed following the click the mouse will be over some
other element and that element likely will get a mouseover event
triggered on it. So in principle the link hovered over by the mouse at
the point when the DIV is hidden (when it is clicked) is the/a link
that generates a mouseover event before the first mouseout event on any
element.

Richard.

Nov 7 '06 #8

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

Similar topics

0
396
by: vince | last post by:
Couldn't find a better place to post the question, feel free to direct me to a better place... Needing to automate our application testing using a keystroke/mouseclick recorder for playing back user events in a Windows form app.... I thought there was something called Microsoft Test, but can't find any info on it... Does Microsoft still make something like this...??? If
3
395
by: jimif_fr | last post by:
How is it possible to simulate the keyboard entries (and the mouse events) of one program, from another program. The first program is not written for this purpose and is a not aware of the simulation.
2
2539
by: | last post by:
Hi everybody. Need your help. How can I play sound (.wav-file / camera click) on mouseclick? TIA willy wuff _______________________________________________________________________________
3
6798
by: Kubik | last post by:
Hello! How to detect mouseclick anywhere on the form? There is a lot of controls on the form, so I don't want to add eventhandler for each of them. How can I do it in another way? Adam -- **remove REM from the mail address**
1
1696
by: perlen | last post by:
I'm trying to write a program that simulates mouse input. I want to be able to send mouseclick- and mousemove - messages to other applications. I tried it using the Journalplayback-Hook, but it didn't work properly because it hung itself up. the other thing why that doesnt work for mi is because i want to get input from a webcam and calculate the mouseposition from this data and then send it to the system. has anyone an idea how this...
4
16741
by: Peter Rilling | last post by:
What is the difference between the MouseClick and Click events?
4
6444
by: Chris Dunaway | last post by:
I added a MouseClick event to a Button control. It responds properly to the Left click of the button, but not a middle click or right click. Is it possible to get a right click and/or middle click for a standard Button control?
6
5172
by: Kristian Frost | last post by:
Hi, I'm trying to add, as you might guess, mouseclick listeners to the shapes I am drawing using the GDI+ commands in a similar sort of way as could be done with the old VB "shapes". Problem is, I'm really not sure of the best way to go about it. I was hoping I could do it directly like the old shape_onclick events, but that doesn't seem to be available for GDIs so maybe I could hack something together using collections of GDI objects and...
2
1403
by: GS | last post by:
how can I tell if it is right mouse click from left mouseclick? I would also to test if a key like control is being held down at the same time. what I would really like to is to capture control right mouse click for debugging purpose. in a generic event handler.
6
1925
by: RolltheBall | last post by:
Hi there. I am trying to make a certain symbol to appear upon every mouseclick. However, the symbol is a cross and an arrow head. This is how I tried to do it. Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _ System.Windows.Forms.PaintEventArgs) Handles _ MyBase.Paint Dim bluePen As New Pen(Color.Blue, 1.5)
0
9802
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
9652
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10558
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
10226
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
9343
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
7765
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
5631
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...
2
3990
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3086
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.