www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: How to stop viewing the Source code?

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Posts
    3

    How to stop viewing the Source code?

    Hi ,
    Can anyone suggest me the code for to stop viewing the source code(No Right Click/Stop People From Viewing Source Code ) for any type of browsers developed in any technology.

    thanks....

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428

  3. #3
    Join Date
    Jan 2004
    Location
    chertsey, a small town s.w. of london, england.
    Posts
    1,463
    Hi there manoj2662,

    why on Earth would you want to stop people from viewing source code.

    Stupid desires like that, suggest to me that you are suffering from megalomania.

    See a doctor before it gets out of hand.

    coothead
    Last edited by coothead; 12-08-2011 at 09:48 AM.

  4. #4
    Join Date
    Dec 2011
    Posts
    3

    Reg: Source Code?

    Hello Buddy...
    I Don't wanna hide anything from the world but just wanna know that the code for it...if itz possible plz let me know orelse thanks for the reply to my post...

  5. #5
    Join Date
    Mar 2011
    Posts
    1,139
    As the others have said above, it is impossible to hide the HTML from users. You can do some things in JavaScript to make it a little complicated for them to see your code, but eventually you have to give the browser access to the real code so it can render the page. And anything a browser can decipher, a user can too.

    Don't waste any time or effort on this. It's not worth it.
    Rick Trethewey
    Rainbo Design

  6. #6
    Join Date
    Dec 2011
    Posts
    68
    Right Click close on the web page you can use below mention script

    <SCRIPT language=JavaScript>
    var message = "function disabled";
    function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ alert(message); return false; }
    if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; } }
    document.onmousedown = rtclickcheck;
    </SCRIPT>

  7. #7
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by mtrick View Post
    Right Click close on the web page you can use below mention script

    <SCRIPT language=JavaScript>
    var message = "function disabled";
    function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ alert(message); return false; }
    if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; } }
    document.onmousedown = rtclickcheck;
    </SCRIPT>
    Please, stop giving false solutions. Once for ever: you can not hide the client-side code.

  8. #8
    Join Date
    Dec 2011
    Posts
    3

    thanks bro...

    thanks bro for that java script......

  9. #9
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by manoj2662 View Post
    thanks bro for that java script......
    When you will implement that in your site, let me know the url, so that I will enter your site, copy all your codes and I will send them back to you by e-mail.

  10. #10
    Join Date
    Nov 2010
    Posts
    86
    Hi. Every web-browser downloads the complete source of your page, and regardless of whether you disable right click or not, the user can save a copy of this code, or view the source from the menus in any mainstream browser, no plugins or special knowledge required.

    Even if browsers didn't allow this, a novice programmer could write a program in less than 3 lines of code to download and save the source of your page, all they have to know is the address.

    If you want you could try making the code hard to understand. There are minifiers and obfuscaters for javascript (which shrink your code or make it hard to read).

    You can also put most of the program logic on the server side so that people can read the output you send them (ie the pages), but not how your web application works (ie how decisions are made and page content is generated).

    What is your purpose in trying to hide your code? If you explain that then maybe there are other ways to achieve what you want.

  11. #11
    Join Date
    Dec 2011
    Posts
    4
    Agree with "Interfacetricks" there is no way to hide the code. With right click disable only beginners or someone who doesn't have much knowledge can be kept away from the code and if someone knows a bit about the code they will also know that in case right click is disabled they can go to File..>Save as menu and save the code locally then view the code. Then there are many applications that can save the complete site with all the css and images.
    Client side code cannot be hidden.

  12. #12
    Join Date
    Dec 2011
    Posts
    32
    If you can view a website in a browser, then there isn't a way to hide source code.

    If you don't want someone to see your source code - don't write it
    Did you do your website html homework today? make french toast bora Stanley Kubrick's 2001 dvd kubrick on DVD.

  13. #13
    Join Date
    Jul 2012
    Location
    INDIA
    Posts
    1
    var message="Function Disabled!";
    function clickIE4(){ if (event.button==2){ alert(message); return false; } }
    function clickNS4(e){ if (document.layers||document.getElementById&&!document.all)
    { if (e.which==2||e.which==3){ alert(message); return false; } } }
    if (document.layers){ document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS4; } else if (document.all&&!document.getElementById)
    { document.onmousedown=clickIE4; }
    document.oncontextmenu=new Function("alert(message);return false")

  14. #14
    Join Date
    Mar 2012
    Posts
    1,509
    Interfacetricks is right, the only way to hide your logic is to put it server-side using PHP or such like. But if your site is simple HTML/CSS there is no way to hide it. The browser has to be able to read the client-side code, so a user can as well. Using scripts to disable functions just pisses off the users. Forget it!

    P.S. Read the sticky at the head of this forum!!!
    Last edited by jedaisoul; 07-14-2012 at 06:01 AM.

  15. #15
    Join Date
    Oct 2013
    Posts
    9

    Hiding or Protecting a Source Code

    Hi Guys, I am new here, but have been in the IT game for more years than you would like to think of.
    In answer to those wishing to hide the source code, let me tell you that it is not possible, no matter what kind of scripts you may use,
    as there is always a work-around method of viewing the source.
    One can encrypt the source, and someone smart comes along and decrypts it.
    The encryption/decription is freely available on the internet.
    Now, just to give you a typical example of websites that you actually cannot view the source.
    All one has to do is copy the address shown in the address bar and download it with a download manager.
    If the source was written in PHP, not a problem, as after you have saved it to your directory, you will notice it
    as video.php or whatever.php. Just rename the .php to .htm or .html, makes not much odds.
    Once done, just double click on the change you have made and the source becomes visible.
    If the visible source is encrypted, then just use the internet to decrypt it.

    That's it guys ..... believe me it works.

    Cheers

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles