# getElementById is killing me

**URL:** <https://forum.kirupa.com/t/getelementbyid-is-killing-me/316749>\
**Category:** web dev\
**Created:** [December 1, 2010, 2:25pm UTC](https://forum.kirupa.com/t/getelementbyid-is-killing-me/316749 "2010-12-01T14:25:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orya](https://avatars.discourse-cdn.com/v4/letter/o/90ced4/32.png) [@Orya](https://forum.kirupa.com/u/Orya)\
**Post date:** [December 1, 2010, 2:25pm UTC](https://forum.kirupa.com/t/getelementbyid-is-killing-me/316749/1 "2010-12-01T14:25:04Z")

</div>

So, I was telling a number of up to 10 Flash-Apps to do some stuff using JS. I was using this code:

```auto

for(var i = 1; i <= 10; i++) {
      if(document.getElementById("swf" + i)) {
          try { document.getElementById("swf" + i).sendToActionScript("stop"); }
          catch(e) { }
      }
}

```

And it worked perfectly in Firefox. IE though? Blinking cursors (switching between the hand-version and the normal one) and flash didn’t receive any orders either.

So I used the version mentioned in the Adobe help files, which was this function:

```auto

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
            return window[movieName];
         } else {
             return document[movieName];
         }
}

```

And changed the existing code accordingly to:

```auto

for(var i = 1; i <= 10; i++) {
      if(thisMovie("swf" + i)) {
          try { thisMovie("swf" + i).sendToActionScript("stop"); }
          catch(e) { }
      }
}

```

It still works in Firefox, but the same bugs in IE. The stupid cursor flickers and it’s unable to locate the SWF-files which Firefox can find easily.

I first gave the SWF-elements just an id with the correct name, then also tried it with both name and id. But the IE refuses to find them.

I wasted so much time on this… anyone can help me please? Why doesn’t this wooooooooooooooork I don’t know. :wt:
