I have a script starting with the comment notaiton in the JSON response. This throws an syntax error in ie7 on runscirpts @ eval(e.text); //run the script.
<script type="text/javascript"><!--
$(document).ready(function(){
//utils.normalizeColumnHeight($('.aboutus-filter-wrapper, .aboutdesc_wrapper,.right_box_wrapper'));
});
// --></script>
Iam executing the scripts using runscripts for ie. here is ths code
runScripts1: function(e) {
if (e.nodeType != 1) return false; //if it's not an element node, return
if (e.tagName.toLowerCase() == 'script') {
//alert(e.text);
eval(e.text); //run the script
}
else {
var n = e.firstChild;
while ( n ) {
if ( n.nodeType == 1 ) forrester.runScripts1(n); //if it's an element node, recurse
n = n.nextSibling;
}
}
return true;
},
how to avoid the comments?
You’re using an invalid commenting construct in the Javascript snippet, furthermore, the closing of the invalid comment context is appropriately commented out while the starting point is present.
That is,
<!-- comment -->construct is valid in HTML//commentor/* comment */constructs are valid in JavascriptBrowsers might not like this at all.
If you’re getting this script as a response from a call somewhere, then I would try first looking at source: do you have control of the output?
If so, change it to remove invalid stuff. If you are getting this code from a service call / external source, I’d recommend not doing so at all. That, though, is perhaps a topic for another question.