473,387 Members | 1,575 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,387 software developers and data experts.

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 2453
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.elementFromPoint(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/elementfrompoint.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.codingforums.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.elementFromPoint(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...@yahoo.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
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...
3
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...
2
by: | last post by:
Hi everybody. Need your help. How can I play sound (.wav-file / camera click) on mouseclick? TIA willy wuff ...
3
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 --...
1
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...
4
by: Peter Rilling | last post by:
What is the difference between the MouseClick and Click events?
4
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...
6
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,...
2
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...
6
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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,...

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.