Ok I created some flash rotator-onclick event to change swf files. But this won't work in IE because the javascript isn't able to create a closing embed tag. Here is the script:

<script type="text/javascript">
	
	var flashNumber = 0;
	var items = 3;
	var i = 0;

		films = new Array(items)
		films[0] = "movies/animals1.swf";
		films[1] = "movies/mammyblue2.swf";
		films[2] = "movies/whitebird1.swf";

		function create(flashNumber){
				
		var obj = document.createElement('object');
			obj.setAttribute('width','400');
			obj.setAttribute('height','300');
			obj.setAttribute('id','test');
			
		var par = document.createElement('param');
			par.setAttribute('name','movie');
			par.setAttribute('value',films[flashNumber]);
			
		var emb = document.createElement('embed');
			emb.setAttribute('src',films[flashNumber]);
			emb.setAttribute('width','400');
			emb.setAttribute('height','300');
			
		var container = document.getElementById('container');
		
			document.body.appendChild(container);
			container.appendChild(obj);
			obj.appendChild(par);
			obj.appendChild(emb);
		
		}
		
		function deleter(){
			
			var d = document.getElementById( 'test' );
			d.parentNode.removeChild( d );
			i++;
			if (i == items)
				i = 0;
			create(i);
			
		}
				
	onload = function(){
	create(0);
	};
</script>

The output HTML is as follows:

<object width="400" height="300" id="test">
      <param name="movie" value="movies/animals1.swf">
      <embed src="movies/animals1.swf" width="400" height="300">
      </object>

You see I can't get the closing embed tag and because of this the script doesn't work in IE

Recommended Answers

All 2 Replies

you could try jquery. Search for "Creating New Elements" at http://api.jquery.com/jQuery/. Chances are you will have to tweak the concept a little to get it to work for your project but because it is jQuery, it will probably work cross browser.

/Close tags are an HTML thing. For elements created in Javascript, they are unnecessary because the code interacts with the DOM directly by creating nodes, which are effectively both "opened" and "closed" as they are created. This is the same in all browsers. In this regard, IE is no different from FF, Opera, Chrome.

If your code is not working then there is another reason.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.