Is Javascript anonymous function persisted? (Using Java applet, way to hide JS code)
I am writing an application using Javascript. I'm looking for a way to hide my code and I believe I found it using a Java applet.
Anyway, I think this should only be possible if the jon's code of the anonymous functions does not remain available in any way after it has been evaluated.
(function(){...}).call(obj)
Applets can get a link to the browser window they are in and call its method eval
to evaluate the js code:
// java code
JSObject window = JSObject.getWindow(this);
window.eval( "(function(){"
+ ...
+ "}).call("
+ thisObjectName
+ ")" );
This way I can change my js code so that some functions instead of the inner code call the applet function, which asks the window for the eval
source code of the js function, navigating to the window anonymous so that the function reference is not saved. Of course, the js function must give the java function the object name ( this
), and the java function must compose an anonymous function adding a method call call(objectName)
to use the reference correctly this
.
MyJsClass.prototype.func = function() { ... };
becames:
MyJsClass.prototype.func = function()
{
...
myApplet.evalJsCode(thisObjectName);
...
};
[UPDATE] My idea was not good for two reasons
source to share