HI,
I've trying to listen for events fried by my ATL object. I find that if I include a script as follows directly in the HTML of the page it picks up the event correctly.
<html>
<head>
<script event="genericScriptEvent(param0, param1, param2, param3, param4, param5, param6, param7, param8)" for="CMyControl" type="text/javascript">
<.head>
...
</html>
However, I'm now creating the html page dynamically and just need to inject the script fragment into the head tag. I've coded up the following method, there are no errors, but it doesn't raise any events once the control is on the page.
function loadJavascriptEventHandler(element, filePath, objectName, callbackFunction)
{
var head = element.doc.getElementsByTagName("head")[0];
var tag = element.doc.createElement('script');
tag.setAttribute('type', 'text/javascript');
tag.setAttribute('src', filePath );
tag.setAttribute('for', objectName );
tag.setAttribute('event', callbackFunction );
head.appendChild(tag);
}
Where "filepath" just contains "genericScriptEvent(param0, param1, param2, param3, param4, param5, param6, param7, param8)"
Is there some dependency on when the script must exist in the page load cycle? (the object is always created after the script tag is added). How else can i dynamically add the event listener script? This problem occurs in IE7.