Javascript-can't create closing tag
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
george61
Junior Poster in Training
59 posts since Jul 2010
Reputation Points: 10
Solved Threads: 6
/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
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372