+ Reply to Thread
Results 1 to 3 of 3

Thread: Javascript help

  1. #1
    Tenant is offline x10Hosting Member Tenant is an unknown quantity at this point
    Join Date
    Jan 2009
    Posts
    13

    Javascript help

    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 by Tenant; 10-23-2009 at 02:15 PM.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Javascript help

    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 by descalzo; 10-23-2009 at 02:30 PM.
    Nothing is always absolutely so.

  3. #3
    Tenant is offline x10Hosting Member Tenant is an unknown quantity at this point
    Join Date
    Jan 2009
    Posts
    13

    Re: Javascript help

    Thank you very much works great.

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 08-17-2008, 01:46 AM
  2. Making a site JavaScript dependent - pros/cons?
    By Tarzan in forum Programming Help
    Replies: 8
    Last Post: 07-11-2008, 10:08 AM
  3. drop down menus with JavaScript disabled?
    By sifaka in forum Free Hosting
    Replies: 1
    Last Post: 05-15-2008, 10:46 AM
  4. javascript and external javascript files problem
    By delon in forum Programming Help
    Replies: 6
    Last Post: 04-27-2008, 12:41 AM
  5. XML and Javascript
    By cuteboytm in forum Graphics & Webdesign
    Replies: 1
    Last Post: 09-21-2007, 10:00 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
x10hosting free hosting for the masses
dedicated servers