Property not supported

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
This code works perfectly in Firefox bu gives errors deselecting in IE 8. Why does this code give a property not supported error on line 10 char 3?
Code:
var selected = Array();

function $(id) {
    return document.getElementById(id);
}

function imgSelect() {
    if (this.className == "selected") {
      //Error line below
       selected.splice(selected.indexOf(this.id), 1);
        document.modify.to_delete.value = selected.join("|");
        this.className = null;
    } else {
        selected[selected.length] = this.id;
        document.modify.to_delete.value = selected.join("|");
        this.className = "selected";
    }
}

var imgs = $("image_box").getElementsByTagName("img");
for (x in imgs) {
    imgs[x].onclick = imgSelect;
}

Which works this HTML:
HTML:
<input type="hidden" name="to_delete" value="" />
<div id="image_box">
   <img src="/images/Test Item 22/thumbnails/Desert.jpg" alt="Desert.jpg" title="Delete?" id="Desert.jpg" />
   <img src="/images/Test Item 22/thumbnails/I Love You.png" alt="I Love You.png" title="Delete?" id="I Love You.png" />
   <img src="/images/Test Item 22/thumbnails/Jellyfish.jpg" alt="Jellyfish.jpg" title="Delete?" id="Jellyfish.jpg" />
   <img src="/images/Test Item 22/thumbnails/Lighthouse.jpg" alt="Lighthouse.jpg" title="Delete?" id="Lighthouse.jpg" />
   <img src="/images/Test Item 22/thumbnails/Penguins.jpg" alt="Penguins.jpg" title="Delete?" id="Penguins.jpg" />
   <img src="/images/Test Item 22/thumbnails/Tulips.jpg" alt="Tulips.jpg" title="Delete?" id="Tulips.jpg" />
</div>
 
Last edited:

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
That is severely disappointing. I have noticed IE's issues with compliance, but I never had an issue with support :thefinger

Thanks very much for the quick response, you saved me a good 30 minutes of headache :)
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
That is severely disappointing. I have noticed IE's issues with compliance, but I never had an issue with support :thefinger

Well, indexOf is a "new" Array property. (JavaScript 1.6, ECMA 5th edition)
 
Top