473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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 2911
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

108
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
40
by: Ron Adam | last post by:
After considering several alternatives and trying out a few ideas with a modified list object Bengt Richter posted, (Thank You), I think I've found a way to make slice operation (especially far end...
0
by: Clemens Hintze | last post by:
Hello, I have a question concerning the usage of default constructed std::slice instances. Our company currently validate the GNU-G++ 3.4 compiler against the ISO/IEC 14882:2003 standard for...
1
by: cylin | last post by:
Dear all, I am a newbie using lex and yacc. I really don't know what's wrong with my code, because the output is not what I want. My yacc rules don't match, and yylex seems just read only one...
23
by: Antoon Pardon | last post by:
Now slices are objects in python, I was wondering if slice notation will be usable outside subscribtion in the future. Will it ever be possible to write things like: a = 4:9 for key, value in...
17
by: baibaichen | last post by:
i have written some code to verify how to disable slicing copy according C++ Gotchas item 30 the follow is my class hierarchy, and note that B is abstract class!! class B { public: explicit...
2
by: smichr | last post by:
It seems to me that the indices() method for slices is could be improved. Right now it gives back concrete indices for a range of length n. That is, it does not return any None values. Using an...
7
by: RubyRedRick | last post by:
I bought Crockford's "JavaScript: The Good Parts" yesterday to help build my JavaScript foo. On page 44, he gives an implementation of the curry function: Function.method('curry', function() {...
5
by: Mike Kent | last post by:
For Python 2.5 and new-style classes, what special method is called for mylist = seq and for del mylist (given that mylist is a list, and seq is some sequence)? I'm trying to subclass list, and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.