Forum Moderators: open

Message Too Old, No Replies

IE <embed> "click to activate" fix doesn't always work

ie embed fix doesn't always work for me

         

jason_hulme

3:32 am on May 14, 2006 (gmt 0)

10+ Year Member



Is anyone else finding that the external JavaScript fix for IE's 'click to active and use this control' doesn't always work?

I have changed the flash headers on 2 sites to write out the embed tags using an external JavaScript. Both sites seem fine 90% of the time but every now and again the 'click to active and use this control' message comes back. I have checked to make sure I wasn't getting a cached page and viewed the source to make sure no embed tag was in the source (except for in the external JavaScript file)

A browser restart seems to fix it and 'click to active and use this control' disappears again.

Could this a bug in the IE 6 patch? Is there better solution to remove the 'click to active and use this control' messages? Has anyone found this happening in IE 7 beta yet?

tedster

12:45 am on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I also think I've been seeing buggy behavior when I use IE since the last update. Problem is, when something only happens once in a while, it's very hard to troubleshoot.

Is there better solution to remove the 'click to active and use this control' messages?

That is the recommended method -- the only one I've heard of in fact.

Fotiman

2:30 pm on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Here's what I do.

Step 1:
Create a file called activeX.js
Paste the following code into that file:


// Attach this to the onload event handler to make sure all of the items
// we're activating are available via the DOM.
function activateActiveX()
{
var activeXObjTypes = new Array( "applet", "embed", "object" );
for ( var i = 0; i < activeXObjTypes.length; i++ )
{
var xObj = document.getElementsByTagName( activeXObjTypes[i] );
for( var j = 0; j < xObj.length; j++ )
{
xObj[j].outerHTML = xObj[j].outerHTML;
}
}
}

Step 2:
In the <head> of your HTML document that contains <object>, <embed>, or <applet> elements, paste the following code:


<script type="text/javascript" src="activeX.js"></script>
<script type="text/javascript">
window.onload = activateActiveX;
</script>

This method does not require that you replace all of your existing objects with a <script> in the middle of your document. Also, for users with JavaScript disabled, they'll still get your ActiveX (though they will still need to click to activate).

pageoneresults

2:36 pm on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What about the SWFObject solution? Is that what we are referring to here? Or, are you using a different JavaScript solution?

<script type="text/javascript" src="swfobject.js"></script>

<div id="flashcontent">This text is replaced by the Flash movie.</div>

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100", "7", "#336699");
so.write("flashcontent");
</script>

Fotiman

2:59 pm on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That method requires that you go through all your existing documents, find your existing objects, applets, and embed tags, and replace them with a bit of JavaScript. It's a lot of work, and the result is that your "content" now has a bunch of "behavioral" crap mixed in. In addition, users with JavaScript disabled will NOT see your ActiveX objects (unless you also include a <noscript> tag, which adds even more mess).

The method I propose does NOT require rewriting your documents. Much cleaner and easier to implement, in my opinion.

Jonathan488

3:17 pm on May 15, 2006 (gmt 0)

10+ Year Member



Fortiman, your solutions sounds like a good idea as a quick fix. The SWFObject solution does require more work, but it also provides more benefits:

  • Eliminating validation errors.
  • Improving accessibility with alternative content
  • Search engine obtimization via the alternative content

Very few visitors support Flash but not JS. Programmed correctly, a page with JS Flash insertion will still show valuable information even when JS/Flash isn't available.

Fotiman

3:31 pm on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




Eliminating validation errors.

Presumably you mean because certain elements, like <applet> are depreciated?


Improving accessibility with alternative content

Alternative content should still be applied using the "alt" attribute of your ActiveX controls, so there's no accessibility benefit with the SWFObject method.


Search engine obtimization via the alternative content

Again, alternative content should be applied to your ActiveX objects anyway, so there's no extra benefit with the SWFObject method.


Very few visitors support Flash but not JS. Programmed correctly, a page with JS Flash insertion will still show valuable information even when JS/Flash isn't available.

Yes, but my method will still show the Flash for ALL users, even those with JS disabled.

zonezleht

7:04 am on May 16, 2006 (gmt 0)

10+ Year Member



I still prefer FlashObject method mentioned above.
Yes it really takes more time to implement it, but with an adition of <noscript> is really an optimal solution.
Let's take an example of navigation.swf which contains main navigation.
Search engines will follow the links in alternate content which is not possible with normal flash embed method. Also users without JS will be still able to navigate my site. And the code will be even valid...as someone mentioned before.
Thumbs up for FlashObject method.

Fotiman

2:57 pm on May 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you're already using the FlashObject method, then obviously it wouldn't make sense to switch over now. My approach is for those who currently have <objects>, <applets>, and <embed> elements within their content and don't want to go through all of them and replace them with <script> and <noscript> versions.

tata668

12:24 am on May 25, 2006 (gmt 0)

10+ Year Member



I tried your technique Fotiman and it works but it flickers a little bit when the outerHTML is changed. But, as you said, it's the perfect technique for someone who doesn't want to change his code too much!

I finally decided to use SWFObject. Here's my code, that also deals with the case where javascript is disabled:


<div id="flashcontent">
<noscript>
<object type="application/x-shockwave-flash"
data="movie.swf"
width="740"
height="130">
<param name="movie" value="movie.swf" />
</object>
</noscript>
</div>
<script type="text/javascript">
<!--
var so = new SWFObject("movie.swf", "demo", "740", "130", "8", "#FFFFFF");
so.write("flashcontent");
//-->
</script>