Script linking in webpages

  • Thread starter Friendly Indian
  • Start date
F

Friendly Indian

How can I include a 'link' to javascript or vbscript in a web
page so all
the javascript
code won't be readily accessible in the source view? I have a
bit of code
and would rather not include it. with the html code. Thanks.

Friendly Indian
 
S

Steve Easton

Or if you want to be stubborn like me
( also known as hard headed )
Copy every thing between the <script></script>
tags into a notepad file and place it between
<--!

//-->
and then save it as yourscript.js in the same location
as the page that will use it.

Reference / call it in the page
with
<script language="javascript" src="yourscript.js">
</script>

between the head tags.

Problem is, yourscript.js is downloaded to the
viewers cache files and they can dig it out and view it
in notepad if they want or know how to.
 
J

Jim Buyens

-----Original Message-----
How can I include a 'link' to javascript or vbscript in
a web page so all the javascript code won't be readily
accessible in the source view? I have a bit of code
and would rather not include it. with the html code.

You can put your JavaScript code in a file with a .js
filename extensions, and then include it with a statement
like:

<script language="JavaScript" src="myscript.js">

However, this provides very little additional security. A
curious visitor can easily open the myscript.js file and
look at it.

Similarly, you can obscure your code by removing all the
white space and using odd variable names. But that
curious visitor can easily reformat the results back to
readability.

In the end, nothing you send to the browser is 100%
secure. If you really want to hide your code, store it
and execute it on the Web server.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
S

Steve Easton

LOL
Good point.
I'm just one of those folks who like
to do it myself.
( aka "The hard way" )
I just "have" to know how it works.

;-)
 
M

MD WebsUnlimited.com

Hi,

Placing your script into an external file does not protect it, it in fact
makes it much easier to collect. To collect an external one would only have
to view the source to see URL of the script file. By entering that location
into the browser, it will download the entire file so that it may be edited
etc.

The benefit of using external files is to provide a common source to apply
changes to if the code is used by several pages, i.e. leveraging code reuse.

There is also a cost to using external files has they cause an other
connection to the server, a file open and close, and in some cases must be
brought to the client in syncronous fashion.
 

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

Top