Can JS code be hidden?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JK

    Can JS code be hidden?

    I wrote a JS for a calculator and would like to prevent visitors from seeing
    or copy/pasting it. I have seen others that seemingly have done this,
    because View Source reveals only a <href:=[website]> and no code. Is this
    what is meant by Client-side/Server-side? If so, please advise how to do, or
    suggest where I might go to discover. (I use DW MX).

    Thank you in advance.

    Jim Kobzeff


  • David Dorward

    #2
    Re: Can JS code be hidden?

    JK wrote:
    [color=blue]
    > I wrote a JS for a calculator and would like to prevent visitors from
    > seeing or copy/pasting it.[/color]

    You can't. The best you could do would be to slap a reminder about copyright
    law at the top, then hire a lawyer if anyone ignores it.
    [color=blue]
    > I have seen others that seemingly have done
    > this, because View Source reveals only a <href:=[website]> and no code.
    > Is this what is meant by Client-side/Server-side?[/color]

    Client side refers to things done by the client. Server side by the server.
    You could have two form fields which the user can enter numbers into. With
    client side JavaScript you could ask the browser to add the numbers
    together and in some way display them to the user. With server side script
    the form data would be sent to your server where a script (which could be
    written in JavaScript, but it isn't a popular server side language) would
    generate a new HTML document with the result in it and send it back to the
    client.

    Server side is reliable.
    Client side is fast.

    Most good solutions use both, the client side to be quick and the server
    side as a fall back position.

    Server side programming is a big topic and largely dependant on the
    capabilities of your server. Talk to your provider about what server side
    scripting facilities are provided, then look for a book or website on the
    subject (if they say they support CGI without specifying a language then
    they probably mean Perl CGI).

    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is

    Comment

    • Evertjan.

      #3
      Re: Can JS code be hidden?

      JK wrote on 04 apr 2005 in comp.lang.javas cript:
      [color=blue]
      > I wrote a JS for a calculator and would like to prevent visitors from
      > seeing or copy/pasting it.[/color]

      Yes you can if you use serverside Jscript/javascript on an ASP platform.

      If you now use clientside javascript, some parts need to be slightly
      rewritten to accomodate client/server interface.
      The serverside formula cannot be seen by the client.

      Example below:

      =============== ==============

      <%@ LANGUAGE=Jscrip t %>
      <%
      var result=""
      var number = Request.form("n umber");
      var multiplier = Request.form("m ultiplier");
      if (!isNaN(number) &&!isNaN(multip lier))
      result=number*m ultiplier;
      %>

      <form method=post>
      <input name=number value=<%=number %>>
      x
      <input name=multiplier value=<%=multip lier%>>
      =
      <%=result%>
      <br>
      <input type=submit value=calculate >
      </form>

      =============== =============== =

      However you will need a [ISP?] server that has ASP.

      --
      Evertjan.
      The Netherlands.
      (Replace all crosses with dots in my emailaddress)

      Comment

      Working...