SitePoint Sponsor |
|
User Tag List
Results 1 to 25 of 47
Thread: Right click... click click
-
Oct 1, 2001, 08:20 #1
- Join Date
- Jun 2001
- Location
- Cape Town, South Africa
- Posts
- 548
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Right click... click click
Hey Y'all,
I've been tryin to prevent visitors from viewing the right-click menu on my pages, and I therefore implemented this most excellent combination of functions and variables only to realise that, no matter what I do, the right-click menu still appears. I was so happy, I decided to turn my PC off.
NOW.. let me explain. My function use to look similliar to the following:
function click(e) {
if (event.button == 2) {
alert("Program cause an illegal opperation, yada yada yada)
return false;
}
}
document.onmousedown = click;
NOTE: I'm only showing the IE versions of my scripts.
After all that effort, everything seemed to be going well, untill I decided to write my own menu. My script then looked like this:
function click(e) {
if (event.button == 2) {
showOnlyMyMenuPlease();
return false;
}
}
document.onmousedown = click;
Whilst having the alert box in my script, the right-click menu did not apear, obviously becuase it's focussing on the Alert box and nothing else, whereas when my DHTML menu pops up, the damn right-click menu apears over mine. HOW WUDE!
Now I've tried event.returnValue and everything else set to false, but no go's.
ANY ideas?- Pip
---------------------------------------------------------------------------------
Nothing takes the taste out of peanut butter quite like unrequited love.
-
Oct 3, 2001, 01:01 #2
- Join Date
- Jun 2001
- Location
- Cape Town, South Africa
- Posts
- 548
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok, so I've successfully accomplished getting this done myself, and should the need ever arise that one of you might need it, well... here you go.
Once again, only the IE version of the script, however I'm sure that with the vast and broad expertise provided through sitepoint forums, you should be able to figure other browser versions out. Netscape would be enclosed within the following statement:
if (document.layers) {
...handle script...
}
whereas IE would be:
if (document.all) {
...handle script...
}
Plain and simply put, one must prevent the context menu from bubbling, so this is how I've done it.
function noContextMenu(e) {
if (event.button == 2) {
event.cancelBubble = true;
event.returnValue = false;
return false;
}
}
document.onmousedown=noContextMenu;
document.onmouseup=noContextMenu;
document.onclick=noContextMenu;
In addition, this is also useful for many other browser features such as dragging, to prevent users from dragging an image on your page to the address bar, etc.
Hope this helped Pip.
Yeah, shot Pip... just what I needed.- Pip
---------------------------------------------------------------------------------
Nothing takes the taste out of peanut butter quite like unrequited love.
-
Oct 3, 2001, 01:07 #3
- Join Date
- Mar 2001
- Location
- Kent, United Kingdom
- Posts
- 5,275
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Pip, why did you want to disable the right click? Many use it for navigation.
Saz: Naturally Blonde, Naturally Dizzy!
No longer Editor of the Community Crier.
Don't mind me, I'm having a BLONDE moment!
-
Oct 3, 2001, 01:29 #4
- Join Date
- Jun 2001
- Location
- Cape Town, South Africa
- Posts
- 548
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's not that I wanted to completely disable the context menu, since I fully agree with you that it's used for navigation, and besides, I tend to use it all the time while surfin', but I wanted to get the look and feel for my site going. You'll see what I mean if you have a look at it.
I still allow users to go back and forth, and if I can find a script that will allow users to view the source, I'd add that menu item into my DHTML menu too. I was also hoping for something that can open the properties for the page, but I think it's working well as is.
BTW, please don't open this page with any other browser than IE5 or later since I myself havent even checked it with other browsers yet, and all my scripts are still only set up for IE. To have a squiz, check it out at http://www.pip.co.za/. Also note that I'm having difficulty viewing my site at the moment, so my host might be having problems, but then again it could also be my lines. I am not sure if I've uploaded the lastest version with my latest script, so if the context menu still appears, if you double-right-click, the context menu won't appear, but only my DHTML menu.- Pip
---------------------------------------------------------------------------------
Nothing takes the taste out of peanut butter quite like unrequited love.
-
Oct 3, 2001, 01:42 #5
- Join Date
- Mar 2001
- Location
- Kent, United Kingdom
- Posts
- 5,275
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Confession: I tried to look at your site earlier
The page wouldn't load then. I'm trying again now, but it seems to be doing the same thing.....just taking ages and appearing to be going nowhere fast!Saz: Naturally Blonde, Naturally Dizzy!
No longer Editor of the Community Crier.
Don't mind me, I'm having a BLONDE moment!
-
Oct 3, 2001, 01:54 #6
- Join Date
- Jun 2001
- Location
- Cape Town, South Africa
- Posts
- 548
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, I've had the same problem. I've been using this QWK.Mon thing, and received a few messages this morning when I got to work. It could be because I haven't paid them yet, but I highly doubt it. It's possibly just them having probs with their servers. It hardly ever happens, so I'll allow it this time, and I can also not complain since I haven't paid yet.
Anyway. Have a look sometime, and let me know what you think.- Pip
---------------------------------------------------------------------------------
Nothing takes the taste out of peanut butter quite like unrequited love.
-
Oct 3, 2001, 01:56 #7
- Join Date
- Mar 2001
- Location
- Kent, United Kingdom
- Posts
- 5,275
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm going to have to look....curiosity has got the better of me!
Saz: Naturally Blonde, Naturally Dizzy!
No longer Editor of the Community Crier.
Don't mind me, I'm having a BLONDE moment!
-
Oct 3, 2001, 02:47 #8
- Join Date
- Jun 2001
- Location
- Cape Town, South Africa
- Posts
- 548
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Groovy, as long as you post a message in here tellin me whocha think, erm... everythin's gonna be alright. I'll keep checking and then post a msg as soon as it's up again... or should that be
if (pip.co.za is ever up again) {
postNewSitepointReply();
} else {
panicAndPayDomain();
}
- Pip
---------------------------------------------------------------------------------
Nothing takes the taste out of peanut butter quite like unrequited love.
-
Oct 12, 2001, 07:24 #9
- Join Date
- Jun 2001
- Location
- Cape Town, South Africa
- Posts
- 548
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Just thought I'd post a reply as stated before. My site is up if youy wanna have a look, although the scripts are slightly out dated to what I have done now. But it should give you an Idea of where I'm going with it.
- Pip
---------------------------------------------------------------------------------
Nothing takes the taste out of peanut butter quite like unrequited love.
-
Oct 12, 2001, 07:59 #10
- Join Date
- Jun 2001
- Location
- Toronto, Canada
- Posts
- 9,123
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Wow is all I've got to say, it's amazing...
btw, view source?
javascript:window.location="view-source:"+window.location.href
-
Oct 12, 2001, 08:05 #11
- Join Date
- Mar 2001
- Location
- Kent, United Kingdom
- Posts
- 5,275
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Pip, you've done something that many fail to do...left me speechless!
Saz: Naturally Blonde, Naturally Dizzy!
No longer Editor of the Community Crier.
Don't mind me, I'm having a BLONDE moment!
-
Oct 12, 2001, 08:05 #12
- Join Date
- Apr 2001
- Location
- Sydney Australia
- Posts
- 869
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Looks great!
affordable website design
:: sydney australia ::
-
Oct 12, 2001, 08:08 #13
- Join Date
- Jun 2001
- Location
- Cape Town, South Africa
- Posts
- 548
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
*Blush!
No reason to get me all shy here guys, common!
I'm glad you likes, and flattered to receive your compliments, but it has changed quite a bit now, and I will update within a week or two. New look includes support for all browsers.
Anycase... thanx again... I am off on leave for a week, so I'll chat to you guys again Monday in a week's time.- Pip
---------------------------------------------------------------------------------
Nothing takes the taste out of peanut butter quite like unrequited love.
-
Oct 12, 2001, 12:31 #14
- Join Date
- May 2001
- Location
- Northern Virginia
- Posts
- 445
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
how did you create that menu? I cant get to your source to look at.
-
Oct 12, 2001, 12:44 #15
- Join Date
- Oct 2000
- Location
- Nashvegas Baby!
- Posts
- 7,845
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Was there something more than that front page? It says "Please be patient" like something is loading.
It's fairly easy to get to view source on his site. It just takes a bit of legwork.
From the front page, select View > View Source. It will show you a frameset. Choose the page you want to look at then load that page into the address bar.
<edit>
Ahhh...smarty pants...it's not that easy. frames/content.asp forwards you to the same page back inside the frameset.
</edit>Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
-
Oct 12, 2001, 12:53 #16
- Join Date
- Oct 2000
- Location
- Nashvegas Baby!
- Posts
- 7,845
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
OK...I finally got to his code...it only took me an extra minute to figure it out.
Did you all mess with the icon in the middle of the page? That rules!Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
-
Oct 12, 2001, 12:54 #17
- Join Date
- Jun 2001
- Location
- Toronto, Canada
- Posts
- 9,123
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Anything else?
2 clues:
1. Right click
2. Hover your mouse over the little P image in the middle of the page, it will lead you deeper in your exploration
-
Oct 12, 2001, 12:55 #18
- Join Date
- Jun 2001
- Location
- Toronto, Canada
- Posts
- 9,123
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Ah man, you beat me
Now you see why we're all drooling
-
Oct 12, 2001, 13:06 #19
- Join Date
- May 2001
- Location
- Northern Virginia
- Posts
- 445
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I still dont understand the right menu... where's the code? How is it done?
-
Oct 12, 2001, 13:46 #20
- Join Date
- Oct 2000
- Location
- Nashvegas Baby!
- Posts
- 7,845
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Javascript offers a method of capturing mouse events. It's basically dHTML. PIP has slaved the right mouse button to a function that shows the user what HE wants you to see instead of what you would normally see.
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
-
Oct 12, 2001, 13:47 #21
- Join Date
- Oct 2000
- Location
- Nashvegas Baby!
- Posts
- 7,845
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So Jeremy...am I missing something then? Is there more to the site or is there just the front page?
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
-
Oct 12, 2001, 13:55 #22
- Join Date
- May 2001
- Location
- Northern Virginia
- Posts
- 445
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
not to piss anyone off... but i'll ask again... HOW?
How does he slave it to his own menu?
-
Oct 12, 2001, 14:57 #23
- Join Date
- Jun 2001
- Location
- Toronto, Canada
- Posts
- 9,123
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Just the frontpage, but isn't it COOL?!!
-
Oct 12, 2001, 18:05 #24
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Not to piss anyone off, but I have your source code right here, it took two seconds to get it using php. I mean your code is cool and all but its not hiding anything from anyone.
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Dec 20, 2001, 12:09 #25
- Join Date
- May 2001
- Location
- Northern Virginia
- Posts
- 445
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
why is this site down?
Bookmarks