Hello,
I have created a context menu in mozilla by using following code:
This code is working perfectly.
Now my context menu is closed when i am moving my mouse out from that window. But what i want is i want to close my contextmenu by clicking any where in window not on mouse out of that context menu.
Do anybody has any solution kindly help me.
Do anybody has any other way to create a context menu. If it is help me.
19 3305 gits 5,390
Recognized Expert Moderator Expert
hi ...
first replace your line 71 with: - document.onclick = function(event) { closeMenu(event) };
and declare the following method: - function closeMenu(e) {
-
var id = 'contextMenu';
-
-
if (e.target.id != id) {
-
document.getElementById(id).style.visibility = 'hidden';
-
}
-
}
-
this should do the job for mozilla :)
kind regards
hi ...
first replace your line 71 with: - document.onclick = function(event) { closeMenu(event) };
and declare the following method: - function closeMenu(e) {
-
var id = 'contextMenu';
-
-
if (e.target.id != id) {
-
document.getElementById(id).style.visibility = 'hidden';
-
}
-
}
-
this should do the job for mozilla :)
kind regards
Hi gits,
Thanks a lot.
But when i am doing left click in the window that context menu is closed but not by the right click of mouse, as default context menu of each window.
When i am doing right click after getting context menu again one context menu is created. Then if i am doing left click the latest menu is closed and the previous one still opened.
Do you have any solution for that.
gits 5,390
Recognized Expert Moderator Expert
nope ... i tested it again in FF 2.0.0.11 ... and when you right-click in the window a new context-menu is created at the mous-pos while the old one is closed ... the right-click is a click too so the click-handler will be called and then the oncontext-menu appears and creates a new one ...
in case you want to ensure that only one contextMenu will be visible then put:
right at the start of your oncontextmenu-handler-function (orig. line 5 of your posted code) ...
kind regards
nope ... i tested it again in FF 2.0.0.11 ... and when you right-click in the window a new context-menu is created at the mous-pos while the old one is closed ... the right-click is a click too so the click-handler will be called and then the oncontext-menu appears and creates a new one ...
in case you want to ensure that only one contextMenu will be visible then put:
right at the start of your oncontextmenu-handler-function (orig. line 5 of your posted code) ...
kind regards
Whatever you have written that is correct. But it is not working. I tried your last solution also.
For each right click i am getting one context menu. Mail me some other way.
gits 5,390
Recognized Expert Moderator Expert
nope ... i don't :) ... you should post your code so that i could trace for the error ... as i said the code i used here works for me ... so may be you did something additionally?
nope ... i don't :) ... you should post your code so that i could trace for the error ... as i said the code i used here works for me ... so may be you did something additionally?
My whole code i am sending you.
With the above i am able to close my context menu by left click.
But after getting one context menu if i am doing right click then again one window is coming. Now if you will do left click then the latest window be closed and the first window is still there.
Check my code and tell me what to do.
Hi gits,
I am working in linux platform. Now i came to know When i am running my code in mozilla of linux platform it is not working means (close the context menu right click is not working). But when i tried it in mozilla of XP it is working.
can you please tell me why it is like this and what to do.
gits 5,390
Recognized Expert Moderator Expert
hi ...
could you see the alert when you change the line to this: - document.onclick = function(event) {
-
alert('test click');
-
closeMenu(event);
-
};
and do a rightclick in the window?
kind regards
PS: please use code tags when posting source-code
hi ...
could you see the alert when you change the line to this: - document.onclick = function(event) {
-
alert('test click');
-
closeMenu(event);
-
};
and do a rightclick in the window?
kind regards
PS: please use code tags when posting source-code
for only left click i am getting alert message. But when trying to close context menu by using right click i am not getting alert.
And one thing that code is working perfectly, according your last post, in mozilla of XP OS not in linux.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Shang Wenbin |
last post by:
Hi,
When I want to close the current window using window.close() in IE6.0,
there will be a confirm box that: The web page you are viewing is trying
to close the window. Do you want to close this window?
I have to click yes to close the window.
How can I close the current window directly without this dialog box?
Thank you.
|
by: Chuck Hartman |
last post by:
I have a Windows service that requests web pages from a site using an
HttpWebRequest object. When I try to request a page from an ASP.NET 2 site,
I get a WebException with message "The remote server returned an error:
(500) Internal Server Error." I found a post that suggested to catch the
WebException to retrieve the actual HttpWebResponse object for more
information. The response returned is shown below.
At first I thought this was a...
|
by: stephen |
last post by:
I have created an order form that users javascript to create a new html
document when the customers clicks the "print page" button.
Once the new document has been created it then prints the document and
closes it with the following code:
<body onload="window.print(); window.close();">
This works correctly (or at least the way I expect it to work under MS
Internet Explorer, but it cuases Netscape to "crash"
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |