?>
<script language=javascript>
window.alert("上传的文件名不能为空,请重新输入!");
history.go(-1);
</script>
<?这个在我这可以,你试试

解决方案 »

  1.   

    这样吧,我把源文件传上来,你们帮我找找哪儿有错。<link href="1.css" rel="stylesheet" type="text/css">
    <?
    if($file_name!=""){
    //-------------数据写入数据库--------------//
      $conn=mysql_connect("localhost","root","");
      $db=mysql_select_db("file");
      $query="insert into file(filename,filetype,filesize,imgnotes)values('$file_name','$file_type','$file_size','$notes')";
      $rt=mysql_query($query);
      mysql_close();
    //--------------防止重名文件---------------//
      srand((double)microtime()*1000000);
      $randval=rand();
      $randval=time().$randval;
      $tmpextname=strrchr($file_name,".");
      $tempffilename=$randval.$tmpextname;
      //echo $tempffilename;
      $cp=copy($file,"file/".$tempffilename);
    //------------判断操作是否成功-------------//
      if($rt&$cp){
      echo "<script language=javascript>";
          echo "window.alert('文件上传成功!');";
          echo "</script>";
      }else{
          echo "<script language=javascript>";
      echo "window.alert('文件上传失败,请检查网络是否通畅!');";
      echo "</script>";
      }
    }else{
        echo "<script language=javascript>";
    echo "window.alert('上传的文件名不能为空,请重新输入!');";
        echo "history.go(-1);";
    echo "</script>";
        exit;
    }
    ?>
      

  2.   

    echo "<script language=javascript>window.alert(\"上传的文件名不能为空,请重新输入!\");history.go(-1);</script>";这样试试?
      

  3.   

    在不行的页面上,点ie菜单上的编辑,然后点查看原代码看看输出的是什么.是不是你期望输出的那个js脚本.
      

  4.   

    function Alert_Msg($Msg,$Url)
    {
    echo "<script language='javascript'>";
    echo "alert('$Msg');";
    echo "var now=new Date();";
    echo "window.navigate('$Url'+now.getTime());";
    echo "</script>";
    }
      

  5.   

    谢谢,谢谢各位了,这个问题最终用bonniewater(陪你去看海)所提供的函数的方法给解决了,但是小弟真的不明白,javascript有时候可以执行得好好的,有时候怎么怎么也执行不成功呢?