-
March 14th, 2006, 09:43 AM
#1
Registered User
hiding javascript
so I've got this fairly long javascript that runs on one of my pages -- how would one go about ...say, loading it into a .js file and calling it from the page? (there's a stupid simple way, I'm sure, I just don't do java much)
-
March 14th, 2006, 11:21 AM
#2
Registered User
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. -Douglas Adams
-
March 14th, 2006, 11:59 AM
#3
Registered User
oh, yea, of course -- say something AFTER I log out editing it for the last few hours.
-
March 14th, 2006, 12:19 PM
#4
Registered User
let me tell ya what I'm trying to do -- the site is sort of helpful, but I need a bit more direction.
I'm using googles map API to do this little page with a few icons on it and some outlines of areas to park. Fairly simple. Here's some of the code...
Code:
function onLoad() {
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-82.002567, 39.9600172), 2);
var point = new GPoint(-83.002915, 39.962176);
var html = "<b>HTML GOODIES</b>";
var marker = createMarker(point, 1, html, icon);
map.addOverlay(marker);
var icon = new GIcon();
icon.image = "picture.jpg"
icon.iconSize = new GSize(30, 30);
icon.iconAnchor = new GPoint(30, 30);
icon.infoWindowAnchor = new GPoint(15, 1);
function createMarker(point, number, name, icon) {
var marker = new GMarker(point, icon);
var html = name;
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
}
}
This is a cut down version, but you get the idea. I'd like to keep that inside the site without "exposing" all the code. I might be overthinking it, I just don't like my code showing
any idea?
-
March 14th, 2006, 04:33 PM
#5
Registered User
Javascript is a scripting language, your code *will* show. Even if you hide it in a .js file someone can still pull it from the server... or if you have the Firefox or IE developer toolbar installed you can see it right away.
If you really, really want to hide code you can write a java applet and compile it into a .class file. But then the user may need to have Java installed... remember XP out of the box doesn't have it.
Protected by Glock. Don't mess with me!
-
March 16th, 2006, 08:39 AM
#6
Registered User
na, fubar no like applets. Not that kind anyway.
oh well, check out what I was working on. http://www.columbuscityattorney.org/map.aspx
-
March 16th, 2006, 08:54 AM
#7
Registered User
Only comment: some redundant stuff with inline styles... since you'e specifying a class anyway... But if it works for you...
Protected by Glock. Don't mess with me!
-
March 16th, 2006, 11:27 AM
#8
I'll agree with CeeBee - while you can do a lot of things (like an include file) to hide JavaScript from casual viewing - anyone who knows what they are doing is going to be able to walk around it and see everything with little or no trouble.
You can always obfuscate your code - extra functions, methods, counting by 3.75s instead of by ones, etc. that make things very messy and hard to understand and hard to copy - but that is extra time for and still futile.
Even if you put it in a .class file there are still decompilers that produce fairly decent JAVA from a class file.
If you want to keep the code away from the users, you will have to go to a server-side technology such as PHP or ASP.
-
March 17th, 2006, 07:36 AM
#9
Registered User
Originally Posted by CeeBee
Only comment: some redundant stuff with inline styles... since you'e specifying a class anyway... But if it works for you...
yea, I know its sloppy I'm just not good with javascript yet. VB, no problem, VBScript? cake, but c#/c++/java/javascript -- my kungfoo no good.
I'd be best using a nested for each loop and maaaayyybeeee XML but I just didn't have the time to hammer out something ...yet. If I get bored today I might.
Similar Threads
-
By GHSTECH in forum Windows XP
Replies: 6
Last Post: September 30th, 2003, 04:48 AM
-
By jamesgiles in forum Windows 95/98/98SE/ME
Replies: 3
Last Post: March 10th, 2003, 05:55 PM
-
By nyht in forum Programming And Web Design
Replies: 6
Last Post: May 11th, 2002, 02:43 PM
-
By Liquidtruth in forum Tech-To-Tech
Replies: 3
Last Post: October 30th, 2001, 07:17 PM
-
By FooL in forum Programming And Web Design
Replies: 2
Last Post: October 3rd, 2001, 08:08 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|
Bookmarks