Using Comments Solution
This solution is very similar to the <div> solution published earlier, however the original <div> solution had a few problems due to the fact that IE would request the swf twice, once for the hidden div, and again when the JavaScript wrote the contents back out again. It also sometimes caused IE to think it was still loading an item, even though the page had finished loading. This solution gets around the problem by preventing IE loading the initial swf by using comments.
First of all create a JavaScript file called, say, ieupdate.js, containing the following code:
This will then need to be included within the <head> tags for each page:
Then you need to include a line directly before, and directy after each <object> tag:
Note: Although the empty comment tag doesn't seem to do anything, it is necessary to get the closing comment tag (-->), otherwise once IE has written out the starting comment tag it will treat everything as a comment until it reaches a closing comment.
As the code is extracted from the comments the swf file isn't requested nor loaded until it is rewritten by the external JavaScript.
First of all create a JavaScript file called, say, ieupdate.js, containing the following code:
var bo_ns_id = 0;
function startIeFix(){
if(isIE()){
document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
}
}
function endIeFix(){
if(isIE()){
document.write('</div>');
var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
var theCode = theObject.innerHTML;
theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"))
document.write(theCode);
}
}
function isIE(){
// only for Win IE 6+
// But not in Windows 98, Me, NT 4.0, 2000
var strBrwsr= navigator.userAgent.toLowerCase();
if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0){
if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6){
return false;
}
if(strBrwsr.indexOf("win98") > -1 ||
strBrwsr.indexOf("win 9x 4.90") > -1 ||
strBrwsr.indexOf("winnt4.0") > -1 ||
strBrwsr.indexOf("windows nt 5.0") > -1)
{
return false;
}
return true;
}else{
return false;
}
}
This will then need to be included within the <head> tags for each page:
<script type="text/javascript" src="ieupdate.js"></script>
Then you need to include a line directly before, and directy after each <object> tag:
<script type="text/javascript">startIeFix();</script>
<object ...
etc etc
</object>
<!-- --><script
type="text/javascript">endIeFix();</script>
Note: Although the empty comment tag doesn't seem to do anything, it is necessary to get the closing comment tag (-->), otherwise once IE has written out the starting comment tag it will treat everything as a comment until it reaches a closing comment.
As the code is extracted from the comments the swf file isn't requested nor loaded until it is rewritten by the external JavaScript.
0 Comments:
Post a Comment
<< Home