Javascript help

Tenant

New Member
Messages
13
Reaction score
0
Points
0
I have been racking my brain trying to find a way to make this work. I have a very large js file that is encrypted and i am selling my software. I want to be able to make some alert boxes editable without to much of a hassle.

Is there a way to do the following.
Code:
<script type="text/javascript">
//Top of js file
var comment = "'Testing the alert system\n\n Amount = ' + amount+"Amount 2 = " +amount2";


// deep within js file
function test(){
    var amount = 50;
    alert(comment);
}
</script>
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Responding to you original javascript...

Code:
// note \\n instead of \n
var comment = "commentX = 'Testing the alert system\\n\\n Amount = ' + amount ;";


// deep within js file
function test(){
    var amount = 50;
//  only use eval on strings you know...
    eval( comment ) ;
    alert(commentX);
}

Another variation...

Code:
var comment = "'Testing the alert system\\n\\n Amount = ' + amount";
// deep within js file
function test(){
    var amount = 50;
    alert(   eval( comment )  ) ;
}
 
Last edited:
Top