SitePoint Sponsor

User Tag List

Results 1 to 25 of 25

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2014
    Location
    iran
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to hide source page?

    Hi, I have a question.
    How can something that no one can see the source page?
    Last edited by Stevie D; Mar 26, 2014 at 03:07. Reason: Unnecessary link removed

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by danialz View Post
    Hi, I have a question.
    How can something that no one can see the source page?
    The only way to stop people seeing the source code is not to publish it on your website. While there are ways to make it more difficult for people, they can't stop people who are determined, and they will always have a negative impact on people using your site in one way or another.

    Why does it matter if people can see your source code anyway?

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,319
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    You could minify it to make it harder to read, but as said, you can't hide it in any practical way. If you think your code is unique, you are probably wrong anyway.

  4. #4
    SitePoint Member
    Join Date
    Mar 2014
    Location
    iran
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no code that will block the source?
    I want the code to be trying to lock this page:
    view-source: siteadress

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,535
    Mentioned
    182 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by danialz View Post
    There is no code that will block the source
    You answered the question yourself

    More info here.

  6. #6
    SitePoint Member
    Join Date
    Mar 2014
    Location
    iran
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This can Block This Page?
    Code:
    view-source:siteadress

  7. #7
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by danialz View Post
    This can Block This Page?
    Code:
    view-source:siteadress
    Nope.

    Besides being different for each browser (each browser has its own way of viewing a page's source), your website itself would have no access to change browser settings.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  8. #8
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by danialz View Post
    Hi, I have a question.
    How can something that no one can see the source page?
    Javascript can disable right clicks > view source > save as, ETC. The down side is people looking at your source usually know how to disabled JS from their browser.

    http://www.htmlgoodies.com/beyond/dh...le.php/3470591

    Example: http://www.metaldetector.com/

    Cant right click.

    Disable Javascript and Viola. Source for the taking. =-)

  9. #9
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by newrykillz View Post
    Javascript can disable right clicks > view source > save as, ETC. The down side is people looking at your source usually know how to disabled JS from their browser.
    This practice is highly discouraged, not to mention annoying. There are perfectly valid reasons to right click on websites (menu options for opening in a new tab, coping URLs, printing, translation, spelling, etc).

    In any case, you can still get to the source even if right clicking is blocked by Javascript. (for example, in Chrome, click the menu button > tools > view source).
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  10. #10
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by newrykillz View Post
    Javascript can disable right clicks > view source > save as, ETC.
    Not if you disable JavaScript or set your browser to disallow JavaScript interfering with the right mouse button.

    The only part of the web page that is under the control of the site author is the content. The browser owner can override the CSS and JavaScript so the page displays and behaves how they want.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  11. #11
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Not if you disable JavaScript or set your browser to disallow JavaScript interfering with the right mouse button.

    The only part of the web page that is under the control of the site author is the content. The browser owner can override the CSS and JavaScript so the page displays and behaves how they want.
    Hence why I stated "The down side is people looking at your source usually know how to disabled JS from their browser. "

  12. #12
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by newrykillz View Post
    Hence why I stated "The down side is people looking at your source usually know how to disabled JS from their browser. "
    But you don't need to disable all of JavaScript to disable "no right click" scripts. Most browsers have an option in their settings that just disables JavaScript's access to interfere with the context menu. You can have that permanently blocked and still allow JavaScript to run.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  13. #13
    SitePoint Wizard webcosmo's Avatar
    Join Date
    Oct 2007
    Location
    Boston, MA
    Posts
    1,480
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You could use a base64 encrypt for your pages, i`m sure people won`t bother trying to decrypt it.

  14. #14
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by webcosmo View Post
    You could use a base64 encrypt for your pages, i`m sure people won`t bother trying to decrypt it.
    The browser would need to be able to decrypt it in order to be able to display the page - that would give people acess to the decrypted version simply by using a browser to decrypt it.

    See http://javascriptexample.net/viewsource.php for how to get the decrypted source either using a simple bookmarklet or userscript in IE, Firefox, Chrome, Safari or Opera
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  15. #15
    SitePoint Member
    Join Date
    Mar 2014
    Location
    Jakarta
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used Javascript on my website to prevent ctr + U function :

    Code:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>
    document.onkeydown = function(e) {
            if (e.ctrlKey && 
                (e.keyCode === 67 || 
                 e.keyCode === 86 || 
                 e.keyCode === 85 || 
                 e.keyCode === 117)) {
                return false;
            } else {
                return true;
            }
    };
    $(document).keypress("u",function(e) {
      if(e.ctrlKey)
      {
    return false;
    }
    else
    {
    return true;
    }
    });
    </script>
    Hope it can help

  16. #16
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by baronintermedia View Post
    I used Javascript on my website to prevent ctr + U function :

    Code:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>
    document.onkeydown = function(e) {
            if (e.ctrlKey && 
                (e.keyCode === 67 || 
                 e.keyCode === 86 || 
                 e.keyCode === 85 || 
                 e.keyCode === 117)) {
                return false;
            } else {
                return true;
            }
    };
    $(document).keypress("u",function(e) {
      if(e.ctrlKey)
      {
    return false;
    }
    else
    {
    return true;
    }
    });
    </script>
    Hope it can help
    A huge script just to attempt to turn off a couple of keypresses that can easily be turned back on. The biggest effect that script will have is to slow the loading of the page so that people don't wait around for it to finish loading - unless they simple disable JavaScript for that page so as to not load the unnecessary script.

    A suggestion to help improve your visitor's experience of your site would be to get rid of that useless script.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  17. #17
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by baronintermedia View Post
    I used Javascript on my website to prevent ctr + U function :

    Code:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>
    document.onkeydown = function(e) {
            if (e.ctrlKey && 
                (e.keyCode === 67 || 
                 e.keyCode === 86 || 
                 e.keyCode === 85 || 
                 e.keyCode === 117)) {
                return false;
            } else {
                return true;
            }
    };
    $(document).keypress("u",function(e) {
      if(e.ctrlKey)
      {
    return false;
    }
    else
    {
    return true;
    }
    });
    </script>
    Hope it can help
    Given that most people view the source code by right-clicking on the page to get the context menu up, or going through the menus, I would be surprised if your script even momentarily stopped more than a handful of people - not to mention the fact that you will then have annoyed them with your petty little script so they will be more determined to find a way round it (which really isn't hard) and then potentially try to sabotage your site, exploit a weakness or just publicise how petty your site management is out of sheer devilment.

    There really is NO reason to try to prevent people from accessing your source code. Really. You just can't do it, and the hassle that you cause when you try isn't worth it.

  18. #18
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Stevie D View Post
    Given that most people view the source code by right-clicking on the page to get the context menu up
    It is just as easy if not easier to press the contextMenu key on the keyboard to bring up the context menu as it is to right click with the mouse.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  19. #19
    Non-Member
    Join Date
    Mar 2014
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think encryption is the best solution for this as above said. Its really worth.

  20. #20
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by aakkam View Post
    I think encryption is the best solution for this as above said. Its really worth.
    WHY? What good does it do you? Absolutely none. It's just selfish and arrogant.

  21. #21
    SitePoint Enthusiast Strider64's Avatar
    Join Date
    Aug 2012
    Posts
    39
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If you're worried about people seeing the source code to the website then in my opinion the website is heading in the wrong direction anyways. What makes a website is the content, for that is what really drives a website. I have seen (I'm sure others have to) websites with great content with a terrible design do very well and websites with lousy content with a great design do terrible. There's a happy medium and that is concentrating on content first and then having a decent to great design. That is why a person designing a website shouldn't go live with it until majority of the content is ready (if realistically possible).

  22. #22
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by aakkam View Post
    I think encryption is the best solution for this as above said. Its really worth.
    That denies access to the page completely to anyone without JavaScript and those who do have JavaScript can still access the source after their browser decrypts it in order to display the page.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  23. #23
    SitePoint Wizard webcosmo's Avatar
    Join Date
    Oct 2007
    Location
    Boston, MA
    Posts
    1,480
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ok, i know! Use flash ) That hides it for sure! And don`t tell me you can use a decompiler ... if you say that, my next answer would be that by using an invisible one, would require an invisible source, so noone can see it!

  24. #24
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by webcosmo View Post
    Ok, i know! Use flash ) That hides it for sure!
    Particularly given that a lot of devices that people use to access the web do not support flash at all.

    Then of course there are all the people who have flash disabled in their browser and who only enable it when they expect to need it.

    You'd be hiding the version you want people to see from a significant fraction of visitors.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  25. #25
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by felgall View Post
    Particularly given that a lot of devices that people use to access the web do not support flash at all.

    Then of course there are all the people who have flash disabled in their browser and who only enable it when they expect to need it.

    You'd be hiding the version you want people to see from a significant fraction of visitors.
    Come on Stephen, you were already in April 1st territory when you posted that, surely you can recognise a wind-up, even if webcosmo was a little bit premature in posting it from the USA


Tags for this Thread

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
  •