hiding javascript
Results 1 to 9 of 9

Thread: hiding javascript

  1. #1
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117

    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)

  2. #2
    Registered User Stalemate's Avatar
    Join Date
    May 2001
    Location
    d4-e5
    Posts
    15,120
    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

  3. #3
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    oh, yea, of course -- say something AFTER I log out editing it for the last few hours.

  4. #4
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    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?

  5. #5
    Registered User CeeBee's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    2,494
    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!

  6. #6
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    na, fubar no like applets. Not that kind anyway.

    oh well, check out what I was working on. http://www.columbuscityattorney.org/map.aspx

  7. #7
    Registered User CeeBee's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    2,494
    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!

  8. #8
    Registered User
    Join Date
    Sep 2000
    Posts
    218
    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.

  9. #9
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    Quote 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

  1. Problems with javascript after SP1
    By GHSTECH in forum Windows XP
    Replies: 6
    Last Post: September 30th, 2003, 04:48 AM
  2. javascript
    By jamesgiles in forum Windows 95/98/98SE/ME
    Replies: 3
    Last Post: March 10th, 2003, 05:55 PM
  3. Javascript --use of reserved word "short"
    By nyht in forum Programming And Web Design
    Replies: 6
    Last Post: May 11th, 2002, 02:43 PM
  4. Javascript...
    By Liquidtruth in forum Tech-To-Tech
    Replies: 3
    Last Post: October 30th, 2001, 07:17 PM
  5. [RESOLVED] JavaScript: Image Loader
    By FooL in forum Programming And Web Design
    Replies: 2
    Last Post: October 3rd, 2001, 08:08 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •