OK Tsuji,
Interesting...I can confirm it was not becuase of the comments but becuase of the if statement, now that I am ignoring the if statment it works fine I ignore it becuase the condition that if statement checks is always false and teh object it checks for always exists, but it seems...
Thanks Kaht,
You were right the eval was not working becuase of the comments , I have removed the comments using split method becuase I know that the first two lines will always be comments , and after stripping those comments eval works like a charm.And no the script does not contain any html...
Thank you kaht and tsuji,
I was trying kaht's suggestion first and it seems the regexp does not replace the comments the string is as it is after the replace with no changes..can you please look into that..
I am using the following code
result2.replace(/\/\/.*\n/g, "");
alert ('Result 2...
This script is auto generated from the portal framework, and is part of teh ajax response which gets populated in the innerHTML of a div element, I need to eval it so that the values it puts the mapping object reflect globally.And thats why I was trying to eval it.
Hello Experts,
I have a scenario where I need to eval a string which contains newline characters..The string result2 has the following script as its value, however when I evaluate the string with eval(result2); it seems it does not get evaluated ..Please let me know if there is a workaround for...
Ok it seems that the problems is that the following code is not being evaluated ...
var result2 has the following value;and eval(result2) has not effect , can anyone shed some light on this aspect of the problem..
Thanks.
result2=
// Build the netui_names table to map the tagId attributes...
I am hiting one roadblock after another after evaluating the script extracted in the above post , I dotn see the values in the netui_names object.I am using the following code to extract the scipt from the above example and evaluating them as follows but I dotn see the values in netui_names...
Lets say you get a Ajax response and in it there are autogenerated javascript functions which you need to be made availabel in a global context, for which they have to evaled, how would you do that??
I am trying to extract the java script in the following text...
// **** This section contains code that will run when the page is loaded ****
// Build the netui_names table to map the tagId attributes
// to the real id written into the HTML
if (netui_names == null)
var netui_names = new...
Now that it seems I cant have the script element populated with the script code in the string var , I have chnaged my approach to extract the java script and evaluate it , I get an error for the following regexp , can anyone please let me know what might be wrong with this RegExp.
Thanks in...
Hello Dan,
Thanks for the reply, I able to print the innerHTML of the head before appending the script element to teh head element.
I have tried multiple scenarios, all of them fail.Before I mention them , just to let you know the JS is in a string not in a file or filename.
Case 1: Try to...
Hello Lee,
Thanks for the reply!Are you asking what the top of teh HTML looks after the head element is appended with a script element? I think the problem Iam facing is that the script element has a src attribute which can only point to a URL ,but in my case I have the script in a variable ...
Hello Jakob,
This is Bob again, your solution works fine when the javascript code has a reference to a file but, can you think of any solution if the retunred response has the actual javascript code in the returned document like <script></script>.The problem is in this case you cant use...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.