Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

Element Behaviour events not triggered

$
0
0

We have a HTC (Element Behavior) which exposes some events for others to subscribe to.  

We found that when event is wired up declaratively then it works in IE11's IE7 Document Mode but not when a handler is directly assigned.  

I have prepared 3 code snippets below.  The wizard.htc, the 'works in ie11 ie7 mode' and 'does not work in ie11 ie7 mode'

  • Does not work in IE11 IE7 Document mode
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head /><body><div id="blahtest" style="behavior: url(wizard.htc)" ><ul id="blah" /><script>
        document.getElementById("blahtest").onBlah = function() {
            alert('2');
        }</script></body></html>
  • Works in IE11 IE7 Document Mode
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head /><body><div id="blahtest" style="behavior: url(wizard.htc)" onBlah="alert('2')"><ul id="blah" /></body></html>

  • Wizard.htc
<public:component><public:EVENT NAME="onBlah" Id="eventOnBlah"/><public:attach event="ondocumentready" handler="ondocumentready_handler"/><script language="javascript">
	    function ondocumentready_handler() {
			var btn = element.document.createElement("BUTTON");
	        btn.innerText = "Click Me";


			btn.onclick = function () {
				eventOnBlah.fire(createEventObject());
			};

			element.document.body.appendChild(btn);
		}

	</script></public:component>

Please run example in "IE11 IE7 Document mode" vs "IE-less-than 11 IE 7 Mode"


1. Has IE11 removed something?  

2. Is there a way to still use the direct assignment method, or indeed, attachEvent or anything of that sort?

Appreciate for a quick reply.

Siew Fai Hoy


Viewing all articles
Browse latest Browse all 3527

Trending Articles