SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 47
  1. #1
    SitePoint Evangelist pip's Avatar
    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.

  2. #2
    SitePoint Evangelist pip's Avatar
    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.

  3. #3
    Bimbo With A Brain! silver trophy Saz's Avatar
    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!

  4. #4
    SitePoint Evangelist pip's Avatar
    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.

  5. #5
    Bimbo With A Brain! silver trophy Saz's Avatar
    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!

  6. #6
    SitePoint Evangelist pip's Avatar
    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.

  7. #7
    Bimbo With A Brain! silver trophy Saz's Avatar
    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!

  8. #8
    SitePoint Evangelist pip's Avatar
    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.

  9. #9
    SitePoint Evangelist pip's Avatar
    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.

  10. #10
    32,817 silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,116
    Mentioned
    1 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
    Digital Hitman, netmobs
    Personal blog: Ensight
    Twitter: @jeremywright

  11. #11
    Bimbo With A Brain! silver trophy Saz's Avatar
    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!

  12. #12
    Net Senior Citizen tommatthews's Avatar
    Join Date
    Apr 2001
    Location
    Sydney Australia
    Posts
    869
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks great!


    affordable website design

    :: sydney australia ::

  13. #13
    SitePoint Evangelist pip's Avatar
    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.

  14. #14
    SitePoint Evangelist jkh1978's Avatar
    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.

  15. #15
    SitePoint Wizard creole's Avatar
    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

  16. #16
    SitePoint Wizard creole's Avatar
    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

  17. #17
    32,817 silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,116
    Mentioned
    1 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
    Digital Hitman, netmobs
    Personal blog: Ensight
    Twitter: @jeremywright

  18. #18
    32,817 silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,116
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ah man, you beat me Now you see why we're all drooling
    Digital Hitman, netmobs
    Personal blog: Ensight
    Twitter: @jeremywright

  19. #19
    SitePoint Evangelist jkh1978's Avatar
    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?

  20. #20
    SitePoint Wizard creole's Avatar
    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

  21. #21
    SitePoint Wizard creole's Avatar
    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

  22. #22
    SitePoint Evangelist jkh1978's Avatar
    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?

  23. #23
    32,817 silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,116
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Just the frontpage, but isn't it COOL?!!
    Digital Hitman, netmobs
    Personal blog: Ensight
    Twitter: @jeremywright

  24. #24
    Dumb PHP codin' cat
    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.

  25. #25
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why is this site down?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •