Can JS code be hidden?

J

JK

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
 
D

David Dorward

JK said:
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).
 
E

Evertjan.

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
Martindap

Latest Threads

Top