🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: microsoft.public.inetsdk.programming.scripting.jscript
12 messages
12 total messages Started by Rafael Rasinger Wed, 29 Sep 1999 00:00
event handler for right mouse button in JS, possible?
#1
Author: Rafael Rasinger
Date: Wed, 29 Sep 1999 00:00
8 lines
1292 bytes
Dear reader!

I am looking for the posibilty to uo use these JS-event handlers, but for
the RIGHT mouse button. Is there a way to do it?

Thank you!

 Rafael
Re: event handler for right mouse button in JS, possible?
#2
Author: Vidar Petursson
Date: Wed, 29 Sep 1999 00:00
35 lines
1664 bytes
Hi

This will do it(Its DOM not Jscript)

function gMouse(){
if(event.button==2) alert("Right button");
}

<body onmousedown="gMouse()">

More info here:
http://msdn.microsoft.com/workshop/c-frame.htm#/workshop/author/default.asp

Note URL may wrap
--
Best Regards
 Vidar Petursson
http://www.icysoft.com
TheKing@icysoft.com
icysoft@vortex.is

No matter where you go there you are
-
Rafael Rasinger <rasinger@atc.co.at> wrote in message
news:37f1c30a@news.kapsch.co.at...
> Dear reader!
>
> I am looking for the posibilty to uo use these JS-event handlers, but for
> the RIGHT mouse button. Is there a way to do it?
>
> Thank you!
>
>  Rafael
>
>
Re: event handler for right mouse button in JS, possible?
#3
Author: Adam Killander
Date: Wed, 29 Sep 1999 00:00
16 lines
1318 bytes
In IE5 you can use the onContextMenu event handler to handle the right
mouse button click.

/Adam Killander 


Rafael Rasinger wrote:
> 
> Dear reader!
> 
> I am looking for the posibilty to uo use these JS-event handlers, but for
> the RIGHT mouse button. Is there a way to do it?
> 
> Thank you!
> 
>  Rafael
Re: event handler for right mouse button in JS, possible?
#4
Author: Rafael Rasinger
Date: Wed, 29 Sep 1999 00:00
50 lines
2182 bytes
Hi Vidar!

Thanx for your answer!

but I need it in JS.
Or at least it should be able to run on Netsc and MSIE

cu, Rafael

Vidar Petursson <icysoft@vortex.is> schrieb in im Newsbeitrag:
uGiUVrlC$GA.291@cppssbbsa02.microsoft.com...
> Hi
>
> This will do it(Its DOM not Jscript)
>
> function gMouse(){
> if(event.button==2) alert("Right button");
> }
>
> <body onmousedown="gMouse()">

> More info here:
>
http://msdn.microsoft.com/workshop/c-frame.htm#/workshop/author/default.asp
>
> Note URL may wrap
> --
> Best Regards
>  Vidar Petursson
> http://www.icysoft.com
> TheKing@icysoft.com
> icysoft@vortex.is
>
> No matter where you go there you are
> -
> Rafael Rasinger <rasinger@atc.co.at> wrote in message
> news:37f1c30a@news.kapsch.co.at...
> > Dear reader!
> >
> > I am looking for the posibilty to uo use these JS-event handlers, but
for
> > the RIGHT mouse button. Is there a way to do it?
> >
> > Thank you!
> >
> >  Rafael
> >
> >
>
>
Re: event handler for right mouse button in JS, possible?
#5
Author: Jim Ley
Date: Wed, 29 Sep 1999 00:00
18 lines
1656 bytes
Rafael Rasinger <rasinger@atc.co.at> wrote in message
news:37f1ea4e@news.kapsch.co.at...
> Hi Vidar!
>
> Thanx for your answer!
>
> but I need it in JS.

You need a lesson in the distinction between Object Models and the Language -
Vidar posted JScript code which did what you asked (although it won't work in
Netscape ISTR, since onMouseDown can't be added inline like that to the body
object - look at captureEvent() in netscape docs - the faq at
http://www.irt.org, or ones listed in the meta-faq at
http://www.squeaky.demon.co.uk/jn/meta-faq.html will answer the question with
complete code..)

Jim.
Re: event handler for right mouse button in JS, possible?
#6
Author: Vidar Petursson
Date: Wed, 29 Sep 1999 00:00
78 lines
2728 bytes
Hi

This should do the trick(Im no NN expert) :P

if(document.all) document.onmousedown=gMouse;
if (document.layers){ window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=gMouse;
}
function gMouse(e){
if(navigator.appName=="Netscape"&&e.which==3) alert("Right button");
else if(event.button==2) alert("Right button");
}


--
Best Regards
 Vidar Petursson
http://www.icysoft.com
TheKing@icysoft.com
icysoft@vortex.is

No matter where you go there you are
-
Rafael Rasinger <rasinger@atc.co.at> wrote in message
news:37f1ea4e@news.kapsch.co.at...
> Hi Vidar!
>
> Thanx for your answer!
>
> but I need it in JS.
> Or at least it should be able to run on Netsc and MSIE
>
> cu, Rafael
>
> Vidar Petursson <icysoft@vortex.is> schrieb in im Newsbeitrag:
> uGiUVrlC$GA.291@cppssbbsa02.microsoft.com...
> > Hi
> >
> > This will do it(Its DOM not Jscript)
> >
> > function gMouse(){
> > if(event.button==2) alert("Right button");
> > }
> >
> > <body onmousedown="gMouse()">
>
> > More info here:
> >
>
http://msdn.microsoft.com/workshop/c-frame.htm#/workshop/author/default.asp
> >
> > Note URL may wrap
> > --
> > Best Regards
> >  Vidar Petursson
> > http://www.icysoft.com
> > TheKing@icysoft.com
> > icysoft@vortex.is
> >
> > No matter where you go there you are
> > -
> > Rafael Rasinger <rasinger@atc.co.at> wrote in message
> > news:37f1c30a@news.kapsch.co.at...
> > > Dear reader!
> > >
> > > I am looking for the posibilty to uo use these JS-event handlers, but
> for
> > > the RIGHT mouse button. Is there a way to do it?
> > >
> > > Thank you!
> > >
> > >  Rafael
> > >
> > >
> >
> >
>
>
Re: event handler for right mouse button in JS, possible?
#7
Author: Rafael Rasinger
Date: Wed, 29 Sep 1999 00:00
88 lines
3307 bytes
Hi Vidar!

Thank you again! A last question. Using your method, which perfectly works,
one problem arises. The contextmenu also appears afterwards. Is there a
possibility to switch it off using script?

Thanx a lot!

> This should do the trick(Im no NN expert) :P
>
> if(document.all) document.onmousedown=gMouse;
> if (document.layers){ window.captureEvents(Event.MOUSEDOWN);
> window.onmousedown=gMouse;
> }
> function gMouse(e){
> if(navigator.appName=="Netscape"&&e.which==3) alert("Right button");
> else if(event.button==2) alert("Right button");
> }
>
>
> --
> Best Regards
>  Vidar Petursson
> http://www.icysoft.com
> TheKing@icysoft.com
> icysoft@vortex.is
>
> No matter where you go there you are
> -
> Rafael Rasinger <rasinger@atc.co.at> wrote in message
> news:37f1ea4e@news.kapsch.co.at...
> > Hi Vidar!
> >
> > Thanx for your answer!
> >
> > but I need it in JS.
> > Or at least it should be able to run on Netsc and MSIE
> >
> > cu, Rafael
> >
> > Vidar Petursson <icysoft@vortex.is> schrieb in im Newsbeitrag:
> > uGiUVrlC$GA.291@cppssbbsa02.microsoft.com...
> > > Hi
> > >
> > > This will do it(Its DOM not Jscript)
> > >
> > > function gMouse(){
> > > if(event.button==2) alert("Right button");
> > > }
> > >
> > > <body onmousedown="gMouse()">
> >
> > > More info here:
> > >
> >
>
http://msdn.microsoft.com/workshop/c-frame.htm#/workshop/author/default.asp
> > >
> > > Note URL may wrap
> > > --
> > > Best Regards
> > >  Vidar Petursson
> > > http://www.icysoft.com
> > > TheKing@icysoft.com
> > > icysoft@vortex.is
> > >
> > > No matter where you go there you are
> > > -
> > > Rafael Rasinger <rasinger@atc.co.at> wrote in message
> > > news:37f1c30a@news.kapsch.co.at...
> > > > Dear reader!
> > > >
> > > > I am looking for the posibilty to uo use these JS-event handlers,
but
> > for
> > > > the RIGHT mouse button. Is there a way to do it?
> > > >
> > > > Thank you!
> > > >
> > > >  Rafael
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: event handler for right mouse button in JS, possible?
#8
Author: Jim Ley
Date: Wed, 29 Sep 1999 00:00
12 lines
1500 bytes
Rafael Rasinger <rasinger@atc.co.at> wrote in message
news:37f20e1b@news.kapsch.co.at...
> Hi Vidar!
>
> Thank you again! A last question. Using your method, which perfectly works,
> one problem arises. The contextmenu also appears afterwards. Is there a
> possibility to switch it off using script?

You need to set the event.returnValue to false - check the documentation!

Jim.
Re: event handler for right mouse button in JS, possible?
#9
Author: Adam Killander
Date: Wed, 29 Sep 1999 00:00
20 lines
1872 bytes
You can't disable the contextmenu unless you're running IE5 since the
right mouse button doesn't fire a click event. You'll have to use the
oncontextmenu event handler in IE5 to disable the context menu. There's
no workaround. Believe me cause I've tried!

/Adam

Jim Ley wrote:
> 
> Rafael Rasinger <rasinger@atc.co.at> wrote in message
> news:37f20e1b@news.kapsch.co.at...
> > Hi Vidar!
> >
> > Thank you again! A last question. Using your method, which perfectly works,
> > one problem arises. The contextmenu also appears afterwards. Is there a
> > possibility to switch it off using script?
> 
> You need to set the event.returnValue to false - check the documentation!
> 
> Jim.
Re: event handler for right mouse button in JS, possible?
#10
Author: Martin Honnen
Date: Wed, 29 Sep 1999 00:00
23 lines
1687 bytes
Yes, you just use one event handler for the document or window object
and then check which button was pressed for instance
 if (document.layers)
    document.captureEvents(Event.MOUSEDOWN);
  document.onmousedown =
    function (evt) {
      if ((document.layers && evt.which == 3) || (document.all &&
event.button == 2)) {
       alert('right mouse button');
       return true;  // use false here to cancel menu in nn
      }
    };

Rafael Rasinger wrote:
> 
> Dear reader!
> 
> I am looking for the posibilty to uo use these JS-event handlers, but for
> the RIGHT mouse button. Is there a way to do it?
> 
> Thank you!
> 
>  Rafael
Re: event handler for right mouse button in JS, possible?
#11
Author: Claude Pelletier
Date: Wed, 29 Sep 1999 00:00
49 lines
2607 bytes
Put that in the header of your page :

var NS4   = (document.layers) ;
var IE4    = (document.all) ;
var IE5    = (navigator.userAgent.indexOf("MSIE 5")>= 0);

function Clique(e){
  if ((NS4 && e.which==3) || IE5 || (IE4 && event.button==2)){
    if(IE4 && !IE5){
       var message =  "L'action du bouton droit de la souris a �t�\n" ;
       var message =  "neutralis�e dans cette partie de la page." ;
       alert(message) ;
   }
    return false;
  }
}
// --------------------------------------------------------------------
if((IE4 || NS4) && !IE5)document.onmousedown = Clique;
if(NS4) document.captureEvents(Event.MOUSEDOWN) ;
if(IE5) document.body.oncontextmenu = Clique;



--
Claude Pelletier
Programmeur, analyste et formateur en informatique
Montr�al (Qu�bec)
clope@total.net

R�alisations sur le web (plusieurs sont en construction) :
    http://www.total.net/~mdjrdp/index.html (DHTML)
    http://www.total.net/~clope/CV/index.html (DHTML)
    http://www.total.net/~clope/indexa.html (DHTML)
    http://www.total.net/~clope/index.html (conventionnel)
    http://www.ccdmd.qc.ca/agora.html (DHTML, SQL)


Rafael Rasinger <rasinger@atc.co.at> wrote in message
news:37f1c30a@news.kapsch.co.at...
> Dear reader!
>
> I am looking for the posibilty to uo use these JS-event handlers, but for
> the RIGHT mouse button. Is there a way to do it?
>
> Thank you!
>
>  Rafael
>
>
Re: event handler for right mouse button in JS, possible?
#12
Author: Rafael Rasinger
Date: Thu, 30 Sep 1999 00:00
62 lines
2845 bytes
Hi Martin!

> Yes, you just use one event handler for the document or window object
> and then check which button was pressed for instance

Thanx a lot! U helped me a lot!

Sorry for asking a lot, but I am kind of new in the JS business.

Just 2 last questions:
1) How can I rewrite the script to enable the rightmouse click function only
when rightclicking a button or <a href>?

2) When I use
"window.open("tt.html","HELP","height=90,width=110,status=no,scrollbars=no")
;" instead of "alert("...")" (see code below) I get the new window and the
context menu in MSIE5, but I only want the window. Is there a way? In NN it
works.

Thanx a lot!


************************

if (document.layers)
    document.captureEvents(Event.MOUSEDOWN);
  document.onmousedown =
    function Clique(evt) {
      if ((document.layers && evt.which == 3) || (document.all &&
event.button == 2))
      {

window.open("tt.html","HELP","height=90,width=110,status=no,scrollbars=no");
       return false;
      }
      else alert("left");
    };
*******************************

>  if (document.layers)
>     document.captureEvents(Event.MOUSEDOWN);
>   document.onmousedown =
>     function (evt) {
>       if ((document.layers && evt.which == 3) || (document.all &&
> event.button == 2)) {
>        alert('right mouse button');
>        return true;  // use false here to cancel menu in nn
>       }
>     };
>
> Rafael Rasinger wrote:
> >
> > Dear reader!
> >
> > I am looking for the posibilty to uo use these JS-event handlers, but
for
> > the RIGHT mouse button. Is there a way to do it?
> >
> > Thank you!
> >
> >  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