Thread View: microsoft.public.inetsdk.programming.scripting.jscript
3 messages
3 total messages
Started by Rafael Rasinger
Fri, 01 Oct 1999 00:00
rightclick of links, buttons, etc..
Author: Rafael Rasinger
Date: Fri, 01 Oct 1999 00:00
Date: Fri, 01 Oct 1999 00:00
54 lines
2402 bytes
2402 bytes
Dear reader!
I am kind of new in the JS business and have encountered the following
problem.
The idea of the JScript is to call a (help-)page when clicking the right
mouse button over a link, button, etc... in both browsers (MSIE and NN). The
code below does it but unfortunately
1) whereever I click the right mousebuttton in the browser window the new
window is opened
2) and in MSIE additionally to the window, the context menu appears.
My
1) How can I prevent the context menu from being opened in MSIE?
2) How can I start the function only when a link, button, etc. is
rightclicked (when leftclicked a default action is performed)?
Thax a lot!
Rafael
***************
<HTML>
<BODY>
<SCRIPT LANGUAGE=javascript>
if (document.layers)
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown =
function ButtonClick(evt) {
if ((document.layers && evt.which == 3) || (document.all &&
event.button == 2))
{
window.open("help.html","HELP","height=200,width=400,status=no,scrollbars=ye
s");
return false;
}
};
</SCRIPT>
<a href="help.html" onMousedown="ButtonClick()">Verweis</a>
<FORM>
<input type=button value="push" onMousedown="Clique()">
</FORM>
</BODY>
</HTML>
***************
Re: rightclick of links, buttons, etc..
Author: Crazy like a fox
Date: Fri, 01 Oct 1999 00:00
Date: Fri, 01 Oct 1999 00:00
11 lines
1397 bytes
1397 bytes
for the first question only add : event.returnValue = false; where you process the right click for the second one test the source of the click : if (event.srcElement.classname == something).... you have to put a class attribute named 'something' in the elements you are going to click on there are other ways to do this of course but this is a simple one regards Nicolas Joguet
Re: rightclick of links, buttons, etc..
Author: Rafael Rasinger
Date: Mon, 04 Oct 1999 00:00
Date: Mon, 04 Oct 1999 00:00
55 lines
2425 bytes
2425 bytes
Dear Crazy like a fox!
Thanks a lot for ur answer! It helped me a lot!
> if (event.srcElement.classname == something)....
> you have to put a class attribute named 'something' in the elements you
> are going to click on
> there are other ways to do this of course but this is a simple one
I have a last question concerning
the possibility of starting a function when a link, button, etc. is
rightclicked (when leftclicked a default action is performed e.g. page is
called)?
What would be the source code for the from u above mentioned example "if
(event.srcElement.classname == something)...." below (when I press the
button)?
***************
<HTML>
<BODY>
<SCRIPT LANGUAGE=javascript>
if (document.layers)
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown =
function ButtonClick(evt) {
if ((document.layers && evt.which == 3) || (document.all &&
event.button == 2))
{
window.open("help.html#Insert","HELP","height=400,width=800,status=no,scroll
bars=yes");
return false;
event.returnValue = false;
}
else openlocation(...);
};
</SCRIPT>
<FORM>
<input type=button value="push" onMousedown="ButtonClick()">
</FORM>
</BODY>
</HTML>
***************
Thank you!
Regards, Rafael
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads