I'm attempting to get this code to work in IE.
The script I have below works fine in Firefox but doesn't work in IE.
Basically this script adds an onclick function to radio buttons of a form which is dynamically generated by a java applet.
(I'm not familiar with the java applet nor do I have any control over it.)
Does anyone have any suggestions to make this work in IE?
The error I get is "ERROR: unterminated string constant"
The error is on line 55 which is the line below starting with inputs[i].onclick.
It seems IE does not like the " on this line. If I escape the " IE does not return an error but the data
does not display correctly in the popinframe() function.
Expand|Select|Wrap|Line Numbers
- var texts = new Array();
- function spanify()
- {
- //addField();
- var inputs = document.getElementsByTagName('input');
- for(var i=0; i<inputs.length; i++)
- {
- var curnode = inputs[i].nextSibling;
- var newSpan = document.createElement('span');
- while(curnode != null)
- {
- if(curnode.tagName != null && curnode.tagName.match(/input/i))
- {
- curnode = null;
- }
- else
- {
- newSpan.appendChild(curnode.cloneNode(true));
- curnode = curnode.nextSibling;
- }
- }
- inputs[i].onclick = new Function("var answers = ('" + megatrim(newSpan.innerHTML.toString()) + "'); popinframe(answers); doSubmit();");
- }
- }
- function megatrim(str) {
- str = str.replace(/'/g, "");
- str = str.replace(/"/g, "");
- str = str.replace(/^\s+|\s+$|\n/g, '');
- return str;
- }