Disable View Source Option

Last post 04-27-2005 12:27 AM by Mikhail Arkhipov (MSFT). 3 replies.

Sort Posts:

  • Disable View Source Option

    04-25-2005, 9:38 PM
    • Member
      5 point Member
    • haroonwangde
    • Member since 04-26-2005, 1:36 AM
    • Posts 1

    I would like to disable View Source Option from the Menu. I am able to disable the Right Click Menu option on the Page.

  • Re: Disable View Source Option

    04-26-2005, 5:54 PM
    • Member
      15 point Member
    • greebler
    • Member since 04-20-2005, 5:52 PM
    • Issaquah, WA
    • Posts 3

    You cannot disable the View Source menu item in the browser using HTML/script.  You might want to investigate encrypting the source so when a users does see it, all they see are garbage characters.  A google search for "view source" and encrypt should get you started.

    Good luck!

  • Re: Disable View Source Option

    04-26-2005, 6:00 PM
    • Star
      14,095 point Star
    • bleroy
    • Member since 04-12-2003, 7:09 AM
    • Redmond
    • Posts 2,296
    • AspNetTeam

    That's not exactly an ASP.NET question, but I'll try to answer. First, you have to know that there is no way you can absolutely protect the source of your page. Any determined hacker will be able to get to it no matter what you do. If the browser can access it to render it, anyone can do it.

    To disable the right click button, you just need to handle the onmousedown event:

    <body onmousedown="if((event.button|2)!=0){alert('Right button disabled');}">

    Bertrand
    ----
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Disable View Source Option

    04-27-2005, 12:27 AM
    I am not really a hacker but it is really simple to get around that right-click protection.

    1. Switch off Javascript in the browser.
    2. Use Edit button on the IE toolbar and open page in Notepad and access images directly via URL.
    3. Save page to disk and inspect file in Notepad.
    4. Use different browser.
    5. In FireFox use DOM inspector and get URL from there.

    There is probably more...
    Thanks

    ------------------------------------------------------------

    This posting is provided "AS IS" with no warranties, and confers no rights.
Page 1 of 1 (4 items)