469,891 Members | 2,173 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,891 developers. It's quick & easy.

What is wrong with the arr.slice(x, y) in IE6?

Hi,

I was wondering whether someone could enlighten me as to the reason why the
slice does not work in IE when the arr is passed in properly.
Checked the values in the srcArr and they are correct so no problems there.
Gecko works as expected.
Prior to entering the function I can slice the array being entered so I
wouldn't expect an "Unexpected call to method or property access" (in IE 6).

I guess its something silly but as of yet i'm not seeing it.
Any suggestions would be appreciated.

TIA
Fermin DCG

===================================
function insertIntoArray(srcArr, insLoc, repl, insObj) {
alert(srcArr.slice(0,2));
var top = (repl) ? srcArr.slice(0, insLoc) : srcArr.slice(0, insLoc1);
var end = (repl) ? srcArr.slice(insLoc+1) srcArr.slice(insLoc+1);
return top.concat(insObj, end);
}
Jul 20 '05 #1
4 2701
"F. Da Costa" <da*****@xs4all.nl> writes:
I was wondering whether someone could enlighten me as to the reason
why the slice does not work in IE when the arr is passed in properly.
It works for me. Need more detail.
Checked the values in the srcArr and they are correct so no problems there.
What is the correct value?
Gecko works as expected.
What is the expected result?
Prior to entering the function I can slice the array being entered so
I wouldn't expect an "Unexpected call to method or property access"
(in IE 6).
Ok. Do you slice it?
I guess its something silly but as of yet i'm not seeing it.
Any suggestions would be appreciated.
function insertIntoArray(srcArr, insLoc, repl, insObj) {
alert(srcArr.slice(0,2));
var top = (repl) ? srcArr.slice(0, insLoc) : srcArr.slice(0, insLoc1);
Undefined variable "insLoc1", should be "insLoc" or "insLoc+1"? If
"insLoc", the branches are equal. If "insLoc+1", the insObj is
inserted *after* the insLoc'th element.
var end = (repl) ? srcArr.slice(insLoc+1) srcArr.slice(insLoc+1); ^ missing ":"

The branches are equal, so no need for conditional expression.
return top.concat(insObj, end);
}


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.

Then I'm sure we will be able to help you. Until we have that information,
all we can do is guess (and while it sometimes seems that way, we are not
oracles :)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Lasse Reichstein Nielsen wrote:
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._s keleton, 'tb1'), true, arr);
var skeleton = top.frmScripts._skeleton;
</script> Just processed tb1

<script>
var skeleton = top.frmScripts._skeleton;
alert("Main::pre render skel.len: "+skeleton.length);
for (var i=0, len=skeleton.length; i<len; i++)
document.write(skeleton[i]);
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[i].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
Jul 20 '05 #3
Lasse Reichstein Nielsen wrote:
It works for me. Need more detail.

Has cost me a whole Sunday trying to figure it out.
Still not resolved but I found an Array extension (prototypes) to include
missing function to IE and that *did* make it work.

I attached the file I found on the web that resolved the whole thing
(obviously you won't benefit but others might ;))

I would like to thank you however for the effort you made to react back.

Cheers,
Fermin DCG
Jul 20 '05 #4
F. Da Costa wrote:
I attached the file I found on the web that resolved the whole thing
(obviously you won't benefit but others might ;))


Please never ever do this again. Attachments in a non-binary group like
this are a Bad Thing. People subscribe to non-binary groups because
they want text content and *small* messages only. Besides, a .js file,
when displayed inline -- and yours should be:

| --------------040106080409010602080206
| Content-Type: application/x-javascript;
| name="ArrayExtension.js"
| Content-Transfer-Encoding: 8bit
| Content-Disposition: inline;
| filename="ArrayExtension.js"

--, could be easily executed. Hopefully nobody has scripting enabled
for his/her newsreader app, otherwise viruses/worms could be easily
distributed, since many people use a e-mail/news client combo. Or they
get a script error due to a restricted DOM or bad syntax, unwished as well.

Post a URI for the file instead, most newsreaders will make it a
hyperlink. Or tell people to send you mail if they want the source
code (another reason why one should post with a valid e-mail address).
Or post it as plain text if it does not exceed, say, 100 lines.

Thanks.
PointedEars
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

108 posts views Thread by Bryan Olson | last post: by
40 posts views Thread by Ron Adam | last post: by
1 post views Thread by cylin | last post: by
23 posts views Thread by Antoon Pardon | last post: by
17 posts views Thread by baibaichen | last post: by
2 posts views Thread by smichr | last post: by
7 posts views Thread by RubyRedRick | last post: by
5 posts views Thread by Mike Kent | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.