26 September 2011

HTML - Fix the 'click to activate and use this control' browser behavior

In recent years browsers require you to click embedded HTML objects before they can become active. Opera will display a tooltip with the message 'Click to activate and use this control' when you hover over one before you clicked it. This behavior can be corrected though, like this:

Create a JavaScript file — I called it FixActivate.js — and put this in it:
var objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++) {
  objects[i].outerHTML = objects[i].outerHTML;
}
Then, at the bottom of any HTML page containing embedded objects, include this file like so:
<script src="FixActivate.js" type="text/javascript"></script>
Now when the page is loaded, the embedded objects are immediately active.

No comments:

Post a Comment