View Full Version : Code only returns my div sporadic

04-07-2006, 11:26 AM
My script failes to execute all lines of code sporadic.

My situation:
I am trying to develop an dynamic solution to microsofts new update to IE6, where all flash objects will need activation to remove an border. I develop an CMS solution so the script needs to be as dynamic as possible.

The goals:
1. I need to load the external script at runtime.
2. I need to be able to check if the file has been loaded.
3. I need to output an div
4. I need to use DOM to append children to that div.

The problem:
When using this with IE I only sporadic get it to display the wanted text in this test.

The suspect:
I suspect it to be the document.writeln in the getContainer function in jsflash.js. I had a problem with IE not loading the external script before calling writeNewDivWithContent so I added the pausecomp function to make it wait a little.

The code:
Sourceview: http://demo.siteman.no/jsflash/kilde.php
The testscript: (Refresh this multiple times in IE and it will only display the wanted text sporadic.

The code:


<script language="Javascript" type="text/javascript">

else {
var skript = document.createElement('script');

function pausecomp(millis)
date = new Date();
var curDate = null;

do { var curDate = new Date(); }
while(curDate-date < millis);

<script language="Javascript" type="text/javascript">
writeNewDivWithContent('testbox','Text to display');


var jsflash_is_loaded = true;

function writeNewDivWithContent(id,text){
newid = CreateContainer(id,text);
var container = document.getElementById(newid);


Checks for existance of this id in document, and prints a div with a uniqe id.
function CreateContainer(ContainerID){

return CreateContainer(ContainerID + "_1");
else {
document.writeln('<div id="' + ContainerID + '"></div>');
return ContainerID;