SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Events in Firefox

    Hello,

    Im trying to essentially disable the right click feature in browsers so that people cant "easily" take pictures off my site, even tho in essence i know they can, its just a deterent.

    Anyway the code im using works exactly how it should in IE, however i cant quite figure out how to get it to work in FF.

    on my image tag i have something like this:
    Code:
    onmousedown="dRightClick(window.event);"
    And my function dRightClick(e); looks like
    Code:
    function dRightButton(e) {
     if (e.button == 2 || e.button == 3 || e.which == 2) {
      alert("Please do not take images off our site!\nThanks, Erica!");
     }
    }
    Ive been doing some reading and ive seen references to stopPropagation();, however something ive noticed, is that even if i put a general alert in the onmousedown in the image tag, it does not execute.

    Any tips on how to get the function to execute in firefox as well as stop that menu from popping up?

    Thanks!
    -voodoo

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Scripts that disable the context menu don't work by default in Firefox. The option for this is under Content > Javascript.

    If you don't want people stealing your images, don't put them on the internet. Disabling right click will probably piss your visitors off. A better solution is to watermark your images. I suppose you could also put the image in a Flash container or put a transparent div over the image.

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool, thanks for the tips!

    btw, what about the fact that the function is not being called? is there another way to add onmousedown to an image so that it will work in firefox

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    According to this e.which should be "3". I don't know why you're testing e.button for 2 and 3 - see the example script on that page.


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
  •