#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    7
    Rep Power
    0

    Disable right button mouse?


    how can I disable the right mouse button over iframe?
    you have any idea?
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,122
    Rep Power
    4258
    Are you sure you want to annoy your users? There are usually ways to get around whatever it is you're trying to block. Some browsers even have an extension that disables right-click-blocking scripts.

    Comments on this post

    • Kastro187420 agrees : I can't believe there are people who still try to do that to people who visit their site =/
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    7
    Rep Power
    0
    Originally Posted by Kravvitz
    Are you sure you want to annoy your users? There are usually ways to get around whatever it is you're trying to block. Some browsers even have an extension that disables right-click-blocking scripts.
    I am sure, you have any idea?
  6. #4
  7. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,122
    Rep Power
    4258
    No way comes to mind that doesn't require directly modifying the document loaded into the iframe.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  8. #5
  9. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,040
    Rep Power
    119
    I have one idea, but it would involve not being able to access the content in the iframe (which your probably going to want to be able to access, so you may not want to do this) and you would have to set the iframe width and height; to the size you want to display it at, because you could not access the scrollbars either. That would be the main drawback for you to have to deal with. You could use a transparent GIF and CSS to cover the contents of the iframe and set the GIF oncontentmenu event to return false.
    Code:
    <style>
    #framedContent {
    width:400px;
    height:300px;
    }
    #framedContent img {
    position:absolute;
    width:400px;
    height:300px;
    }
    #framedContent iframe {
    width:400px;
    height:300px;
    }
    </style>
    
    <div id="framedContent">
    <img src="http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif" oncontextmenu="return false"/>
    <iframe src="http://forums.devshed.com/" scrolling="no"></iframe>
    </div>
    This idea would only be good, if you just are basically wanting to have the page view-able through a figurative window. This is an old advert idea/concept; that is still commonly used by online advertising/marketing companies, such as PointRoll. Otherwise, my advice would be to scrape the content, of the page, your putting in your iframe and display the scraped content back into your page in an element, like a div. Then set-up your CSS for this div; with a specific height and width. Then set the overflow to auto and/or give it a border. This would give the impression of a iframe and if someone tried to open a context menu, the content would be in your page; so it would look like it's your content, but maybe that would not matter to you, either way. Assumingly, your not wanting someone to see your source code, because your not wanting it to be stolen, but their are several ways around this. So basically and overall..., I would have to agree with Kravvitz.

    Comments on this post

    • sonny3 agrees : good idea
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    7
    Rep Power
    0
    Originally Posted by web_loone08
    I have one idea, but it would involve not being able to access the content in the iframe (which your probably going to want to be able to access, so you may not want to do this) and you would have to set the iframe width and height; to the size you want to display it at, because you could not access the scrollbars either. That would be the main drawback for you to have to deal with. You could use a transparent GIF and CSS to cover the contents of the iframe and set the GIF oncontentmenu event to return false.
    Code:
    <style>
    #framedContent {
    width:400px;
    height:300px;
    }
    #framedContent img {
    position:absolute;
    width:400px;
    height:300px;
    }
    #framedContent iframe {
    width:400px;
    height:300px;
    }
    </style>
    
    <div id="framedContent">
    <img src="http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif" oncontextmenu="return false"/>
    <iframe src="http://forums.devshed.com/" scrolling="no"></iframe>
    </div>
    This idea would only be good, if you just are basically wanting to have the page view-able through a figurative window. This is an old advert idea/concept; that is still commonly used by online advertising/marketing companies, such as PointRoll. Otherwise, my advice would be to scrape the content, of the page, your putting in your iframe and display the scraped content back into your page in an element, like a div. Then set-up your CSS for this div; with a specific height and width. Then set the overflow to auto and/or give it a border. This would give the impression of a iframe and if someone tried to open a context menu, the content would be in your page; so it would look like it's your content, but maybe that would not matter to you, either way. Assumingly, your not wanting someone to see your source code, because your not wanting it to be stolen, but their are several ways around this. So basically and overall..., I would have to agree with Kravvitz.
    this is a good idea, thanks

IMN logo majestic logo threadwatch logo seochat tools logo