Java script doubt i want protect the java script code without view source

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srinivask
    New Member
    • Jan 2007
    • 7

    Java script doubt i want protect the java script code without view source

    hai

    just tell that how can i protect the java script code without seeing view source

    it should not the code.

    i want function to perform
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by srinivask
    hai

    just tell that how can i protect the java script code without seeing view source

    it should not the code.

    i want function to perform
    Maybe should have asked in the Javascript forum.

    Do not put the Javascript in the HTML files. Simply put a link to the source of the js so that all people can see is a link of where the scripts are coming from not the scrips themselves

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Why do you want to hide Javascript anyway? If it's important info. that shouldn't be viewed by the user, use the server side language.

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Originally posted by r035198x
        Do not put the Javascript in the HTML files. Simply put a link to the source of the js so that all people can see is a link of where the scripts are coming from not the scrips themselves
        This wont help against anyone with 1/2oz of knowledge.

        Comment

        • Ganon11
          Recognized Expert Specialist
          • Oct 2006
          • 3651

          #5
          Moving this thread to the Javascript forum...

          Comment

          • mgast
            New Member
            • Sep 2006
            • 9

            #6
            Try using

            Code:
            document.oncontextmenu = function() { return false; }
            Be warned though - this will disable right click on ALL types of elements, including some you may want to grant access to. It also won't prevent them from clicking view -> page source in the browser menu.

            Comment

            • UniDyne
              New Member
              • Oct 2005
              • 18

              #7
              Let me start by saying all the techniques for hiding JavaScript code can be exposed. It is a script language; it gets interpreted, not compiled, so the source always remains intact in some fashion.

              If IE is the only thing you are going to use, then you can "encode" your javascript into .jse files.



              This is really nothing more than a special Base64 encoding.

              If you want compatibility, you can use the Crunchinator, which makes the JS harder to read by eliminating all white space and formatting:



              Or, you can use Huffman compression on your JS:

              Comment

              • nmsreddi
                Contributor
                • Jul 2006
                • 366

                #8
                Hello

                The simple and easiest way just write java script in .js file and call that link in your html code.

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Originally posted by UniDyne
                  Let me start by saying all the techniques for hiding JavaScript code can be exposed. It is a script language; it gets interpreted, not compiled, so the source always remains intact in some fashion.

                  If IE is the only thing you are going to use, then you can "encode" your javascript into .jse files.



                  This is really nothing more than a special Base64 encoding.

                  If you want compatibility, you can use the Crunchinator, which makes the JS harder to read by eliminating all white space and formatting:



                  Or, you can use Huffman compression on your JS:

                  http://rumkin.com/tools/compression/compress_huff.php
                  I definitely would not recommend anything IE-specific especially with more and more people using other browsers. The others are viable options, though as you mention there are no foolproof solutions. One other possibility is to use an encode/decode option as described here.

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Originally posted by nmsreddi
                    Hello

                    The simple and easiest way just write java script in .js file and call that link in your html code.
                    Then I can just look in the source code using View Source, see the link to the file and download the file to view for my pleasure!

                    Comment

                    Working...