0

I tried to load flash (swf file) either from external sources or local sources,

I use object tag in html to contain the flash for some reason, if I load the flash directly in the object tag, it will work flawlessly, like this:

<object height="100" width="100" data="helloworld.swf" id="flash"></object>

Next, I need to load the flash dynamically from JavaScript, but several problems arise:

var flash=document.getElementById("flash");
flash.setAttribute("data","helloworld.swf");

the code above works fine in Chrome, but it doesn't do anything in IE (my IE is IE11 on windows 8)

If I modify the object tag to iframe tag, then it works, but I need it to be object tag,

Any solutions come to mind?

3
  • So why not use var flash=document.getElementById("object"); instead of var flash=document.getElementById("flash");? Commented Aug 7, 2014 at 11:41
  • There's no DOM element with "object" as the ID Commented Aug 7, 2014 at 11:43
  • Ow sorry, I was thinking of createElement. Try cloning and replacing it. Flash is very persistent. Commented Aug 7, 2014 at 11:47

2 Answers 2

3

You can force the refresh by readding the object:

var flash = document.getElementById("flash");
flash.setAttribute("data","helloworld.swf");

var clone = flash.cloneNode(true);
flash.parentNode.replaceChild(clone, flash);
Sign up to request clarification or add additional context in comments.

Comments

0

Use SWFObject. It will save you from all the cross-browser compatibility troubles.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.