Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 991 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Javascript :

Disabling Middle Click?

Thread title: Disabling Middle Click?
Reply    
    Thread tools Search this thread Display Modes  
12-30-2009, 03:25 PM
#1
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old  Disabling Middle Click?

What is the best method of disabling middle click?

I'm trying to stop users scrolling a page this way.

Reply With Quote
12-30-2009, 05:48 PM
#2
Gaz is offline Gaz
Gaz's Avatar
Status: Request a custom title
Join date: Apr 2007
Location: UK
Expertise: Code & Programming
Software: Coda, TextMate, Sublime 2
 
Posts: 2,097
iTrader: 26 / 100%
 

Gaz will become famous soon enough Gaz will become famous soon enough

Send a message via Skype™ to Gaz

  Old

Quirksmode has a good section on this:
http://www.quirksmode.org/js/events%...es.html#button

Another good article:
http://unixpapa.com/js/mouse.html

Google also helps
http://www.google.com/search?q=middl...ent+javascript

However, I'd use jQuery.
Code:
$("#foo").live('click', function(e) { 
   if( e.which == 2 ) {
      e.preventDefault();
      alert("middle button"); 
   }
});
.. where preventDefault() function prevents the default function of the middle click (the alert can be removed).

Hope that helps

Reply With Quote
12-31-2009, 04:25 AM
#3
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

Thanks Gaz. (:

My searches proved futile, was about to give up hope.

Reply With Quote
12-31-2009, 04:26 AM
#4
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Just remember that it is javascript so anyone can easily bypass it.

Reply With Quote
12-31-2009, 04:35 AM
#5
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

Indeed. But it's intention is good. Nothing malicious in it, just to stop people getting lost while navigating.

Reply With Quote
12-31-2009, 04:38 AM
#6
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Ok, no worries then.

Reply With Quote
01-30-2010, 10:01 PM
#7
c69 is offline c69
c69's Avatar
Status: Junior Member
Join date: Nov 2009
Location: Kiev, Ukraine
Expertise:
Software:
 
Posts: 27
iTrader: 0 / 0%
 

c69 is on a distinguished road

  Old

Originally Posted by Dan View Post
Indeed. But it's intention is good. Nothing malicious in it, just to stop people getting lost while navigating.
getting lost ??? o_O, sorry for offtopic but maybe you should try to make your page less confusing in that case?

because with disabling middle click you will only stop them from scrolling with MOUSE, but not with arrows or space

Reply With Quote
01-31-2010, 03:06 PM
#8
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

Originally Posted by c69 View Post
getting lost ??? o_O, sorry for offtopic but maybe you should try to make your page less confusing in that case?

because with disabling middle click you will only stop them from scrolling with MOUSE, but not with arrows or space
I didn't mention I was allowing arrow keys either. ;-)

Yes. Getting lost. (:

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed