var isIe=(document.all)?true:false; function mousePosition() {
return{
x:(document.body.scrollWidth+340)/2,y:(document.documentElement.clientHeight - 100) / 2
}

function showMessageBox(wTitle,content,pos,wWidth) { 
closeWindow();
var bWidth=parseInt(document.body.scrollWidth); 
var bHeight=parseInt(document.documentElement.scrollHeight);  var mesW=document.createElement("div"); 
mesW.id="mesWindow";
mesW.className="mesWindow";
mesW.innerHTML="<div class='mesWindowTop'><table width='100%' height='100%'><tr><td>"+wTitle+"</td><td style='width:1px;'></td></tr></table></div><div class='mesWindowContent' id='mesWindowContent'>"+content+"</div>";
styleStr="left:"+(((pos.x-wWidth)>0)?(pos.x-wWidth):pos.x)+"px;top:"+(pos.y)+"px;position:absolute;width:"+wWidth+"px;";
mesW.style.cssText=styleStr;
document.body.appendChild(mesW);
}
function closeWindow() {
if(document.getElementById('mesWindow')!=null){
document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
}
}
function testMessageBox(moviename){
var objPos = mousePosition();
messContent="<div id='dis_1' style='padding:0px;color:#000000;text-align:left;line-height:200%;'>"+
"<input type='text' id='chart' size='46' style='font-family:Arial; font-weight:bolder; color:#cccccc; background-color:#000000; padding:0px; border-style:none;'></div>";
showMessageBox('《'+moviename+'》影片加载中…… <span id="percents"></span>',messContent,objPos,340);
playmovie(moviename);
}
var bar = 0;
var bar2 = 0;
var line = "|";
var amount ="|";
function playmovie(moviename){
bar= bar+1;
amount =amount + line;
$('chart').value=amount;
$('percents').innerText=bar+"%";
if (bar<=100) 
{
if(bar < 100){
if($('Player').GetPlayState()===3){
closeWindow();
$("bodydiv").style.display="";
}else{
setTimeout("testMessageBox('"+moviename+"')",300);
}
}else{
closeWindow();
$("bodydiv").style.display="";
}

}
function checkwrong(){
bar2= bar2+1;
if (bar2<=40){
if(bar2 < 40){
if($('Player')){
if($('Player').GetPlayState()===3){
}else{
setTimeout("checkwrong()",1000);
}
}
}else{
insert_err();
}
}
}

解决方案 »

  1.   

    我又把这个JS文件单独用另一个简单的文件加载,不过效果是完全正确的,这说明JS没错,错在与外部其它什么地方有某种冲突,继续研究<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> new document </title>
     </head> <body>
    播放器,ID为Player
    <script src=div.js></script>
    <script>
    function $(id){return document.getElementById(id);}testMessageBox("moviename");
    </script>
     </body>
    </html>
      

  2.   

    ie在文档未加载完成时调用document.body.appendChild会出问题
      

  3.   

    6楼正解,body加载完之后,我再用了setTimeout('testMessageBox("<?=substr($r[title],0,30)?>")', 200);完成多谢