Lasse said:
The code is syntactically incorrect. Please post the actual code that
fails, and say what you do (the actual values of the arguments that
fail), what you expect to happen (the final result, or even the vlaues
of top and end), and what actually happens.
I understand, so i'll first present the html code from where the call is
made followed by the js code used.
Note:
Working env contains two frames. 1 for scripts (like a library with
accessible variables) & the other for showing content.
Clicking on a link gets one into the page as shown below.
Verified:
The existence (with contents) of *top.frmScripts._skeleton*.
The creation and fill of *arr*.
IE immediately jumps to the last render <script> whilst Gecko goes in and
comes back with an extended *top.frmScripts._skeleton* (which is what i
intended for it to do).
Entering the function goes as planned & all the variables are filled as
expected. Also did an alert() check in IE.
The monment it hits the slice statement it falls over on the first slice
request. So it does *not* slice in the alert.
My feeling (for what its worth):
It is almost as if there is something of a type change. From Array to
something that does *not* support the slice method (judging by the error
reported, Unexpected call to method or property access).
I hope this is complete enough to help me underatand what i'm doing wrong.
=== .html ===
<body>
<div id="doc">
<h3>This is the MAIN div</h3>
<script>
var arr = new Array();
arr.push('<tbody id="ognl:scriptParameter">');
arr.push('<tr><td >row-0 -:- col-0</td><td>row-0 -:-
col-1</td></tr><tr><td>row-1 -:- col-0</td><td>row-1 -:-
col-1</td></tr><tr><td>row-2 -:- col-0</td><td>row-2 -:- col-1</td></tr>');
arr.push('</tbody>');
top.frmScripts._skeleton = insertIntoArray(top.frmScripts._skeleton,
top.frmScripts.getTbodyIndexById(top.frmScripts._skeleton, 'tb1'), true, arr);
var skeleton = top.frmScripts._skeleton;
</script> Just processed tb1
<script>
var skeleton = top.frmScripts._skeleton;
alert("Main:
re render skel.len: "+skeleton.length);
for (var i=0, len=skeleton.length; i<len; i++)
document.write(skeleton
);
skeleton = null;
</script>
</div>
</body>
=== CreateTbody.js === can be found in the frame called frmScripts
function getTbodyIndexById(tableSkeleton, tbodyID) {
for (var i=0, len=tableSkeleton["length"]; i<len; i++) {
if (tableSkeleton.indexOf(tbodyID)>1) return i;
}
return 0;
}
/**
* This function can be used to insert an element or another array into an
array.
* @param sourceArray = the array into which one wants to do the insertion
* @param insertLocation = the location (int) where the insertion needs to
take place
* @param replace = boolean indicating what should happen to the element
on insertLocation
* @param insertObject = the object (string || array) to be inserted
*
* @return the array with the inserted data
*/
function insertIntoArray(sourceArray, insertLocation, replace, insertObject) {
alert("insert:: slice test = "+tmp.slice(0,2));
var top = (replace) ? sourceArray.slice(0, insertLocation) :
sourceArray.slice(0, insertLocation+1);
var end = (replace) ? sourceArray.slice(insertLocation+1) :
sourceArray.slice(insertLocation+1);
return top.concat(insertObject, end);
}
all we can do is guess (and while it sometimes seems that way, we are not
oracles
If not that then definitely 'see-ers'
TIA
Fermin DCG