I am trying to load a bunch of .NET hosted controls into a page dynamically using JavaScript to inject OBJECT tags into the HTML.
My problem is that the objects do not instantiate, only the static object that is visible on page load will appear. Is there any way to get these objects to load?
<h1>
Visible static</h1>
<div id="staticObject">
<object id="Object1" name="dropfolder" classid="http:DropFolder.dll#DropFolder.DropFolder">
<param name="FolderName" value="Intranet only - Worcs">
<param name="NodeKey" value="default|Intranet">
<param name="DropAction" value="">
</object>
</div>
<h2>
Hidden static</h2>
<div id="objwrap" style="display: none;">
<object id="default_Intranet" name="dropfolder" classid="http:DropFolder.dll#DropFolder.DropFolder">
<param name="FolderName" value="Intranet only - Worcs">
<param name="NodeKey" value="default|Intranet">
<param name="DropAction" value="">
</object>
</div>
<input type="button" value="unhide!" onclick="document.getElementById('objwrap').style.display = 'block';" />
<h2>
OnLoad target</h2>
<div id="objectTarget1">
</div>
<h2>
Click target</h2>
<div id="objectTarget2">
</div>
<input type="button" value="inject" onclick="javascript:inject('objectTarget2');" />
<script type="text/javascript">
function inject(target) {
var target = document.getElementById(target);
target.innerHTML =
'<object id="default_Intranet" name="dropfolder" classid="http:DropFolder.dll#DropFolder.DropFolder">' +
'<param name="FolderName" value="Intranet only - Worcs">' +
'<param name="NodeKey" value="default|Intranet">' +
'<param name="DropAction" value="">' +
'</object>';
};
inject('objectTarget1');
</script>