By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,774 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,774 IT Pros & Developers. It's quick & easy.

Can JS code be hidden?

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jul 23 '05 #2

P: n/a
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)

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.