0

I want to add a variable and add something to a functions content.

var variable1;

function myFunction() {
    alert(variable1);
    return variable1;
}

I want to change that to:

var variable1;
var variable2;
function myFunction() {
    alert(variable1);
    alert(variable2);
    return variable1;
}

I want that the changes are applied to a my main html file so that the next time the page is called the changes are in effect.

I already have a Servlet that can produce a new html page but I don't know how to change the JavaScript part of an already existing page.

Edit: so basically I need something like:

 request.getFunction(myFunction).addBeforeReturn(alert(variable2));
Alexandre Neukirchen
  • 2,713
  • 7
  • 26
  • 36
Selphiron
  • 897
  • 1
  • 12
  • 30
  • Is the javascript embedded in the html your are producing? – Yellen Mar 09 '15 at 12:19
  • 1
    This might help [http://stackoverflow.com/a/2413453/2850474](http://stackoverflow.com/a/2413453/2850474) – amarnath Mar 09 '15 at 12:22
  • 1
    If you already have the servlet producing HTML content what prevents you from adding few more lines to that code? – RaviH Mar 09 '15 at 12:25
  • thx for the answers I edited my question abit to make my point clear. @yellen : yes but I could change that if that is a major problem (quite new to javascript and html) – Selphiron Mar 09 '15 at 12:44
  • @amarnath thx that tells me how to add a variable, so now I need a way to edit functions – Selphiron Mar 09 '15 at 12:44
  • @RaviH yes but that is not what I want. I want to edit the main html file's javascript part. Pls read again the sentence before that where I state that I have a Servlet that... – Selphiron Mar 09 '15 at 12:44
  • @Selphiron I give up! – RaviH Mar 09 '15 at 12:47

0 Answers0