Can JS code be hidden?

Discussion in 'Javascript' started by JK, Apr 4, 2005.

  1. JK

    JK Guest

    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
    JK, Apr 4, 2005
    #1
    1. Advertising

  2. JK wrote:

    > I wrote a JS for a calculator and would like to prevent visitors from
    > seeing or copy/pasting it.


    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.

    > 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?


    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
    David Dorward, Apr 4, 2005
    #2
    1. Advertising

  3. JK

    Evertjan. Guest

    JK wrote on 04 apr 2005 in comp.lang.javascript:

    > I wrote a JS for a calculator and would like to prevent visitors from
    > seeing or copy/pasting it.


    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=Jscript %>
    <%
    var result=""
    var number = Request.form("number");
    var multiplier = Request.form("multiplier");
    if (!isNaN(number)&&!isNaN(multiplier))
    result=number*multiplier;
    %>

    <form method=post>
    <input name=number value=<%=number%>>
    x
    <input name=multiplier value=<%=multiplier%>>
    =
    <%=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)
    Evertjan., Apr 4, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    4
    Views:
    9,121
  2. freenews.netfront.net
    Replies:
    2
    Views:
    3,880
    Daniel Fisher\(lennybacon\)
    Nov 14, 2005
  3. Daniel

    Hidden code in emails

    Daniel, Apr 17, 2008, in forum: HTML
    Replies:
    10
    Views:
    761
    Raymond SCHMIT
    Apr 22, 2008
  4. Rick
    Replies:
    3
    Views:
    8,092
    Alexey Smirnov
    Apr 13, 2010
  5. SolarCanine
    Replies:
    2
    Views:
    251
    SolarCanine
    Sep 20, 2005
Loading...

Share This Page