2010-07-19 37 views
0

任何人都可以看到为什么这将工作在FF但不是Safari?当我提醒处理图像的CF脚本返回并返回它在FF中工作的图像名称时。在Safari没有去...我的jquery代码被劫持的iframe图片上传工作在FF,而不是Safari。有任何想法吗?

$("#uploadform").submit(function(objEvent){ 
      //alert("Submit"); 

       var jThis = $(this); 
       var strName = ("uploader" + (new Date()).getTime()); 
       var jFrame = $("<iframe name=\"" + strName + "\" src=\"about:blank\" />"); 
       jFrame.css("display", "none"); 
       jFrame.load(function(objEvent){ 
        var objUploadBody = window.frames[ strName ].document.getElementsByTagName("body")[ 0 ]; 
        var jBody = $(objUploadBody); 
        var objData = eval(jBody.html()); 
        var thumb = ('holding/' + eval(jBody.html())); 
        setTimeout(function(){ 
         jFrame.remove(); 
          },100); 
       if (objData !== '') { 
        // Put the preview here and load another form that has a hidden element capturing the image name 
        // then use a button to save the image, close the window and update the database with all the info 
        // and relaod the main page with a location.reload 

        $('#imagePreview').attr('src', thumb); 
        $('#imageName').html(thumb); 
        $('#imagePreview').click(function(){ 
         rebinder(); 
         }); 
        } else { 
         alert("no thumbnail"); 
        } 
      }); 
      $("body:first").append(jFrame); 
      jThis 
      .attr("action", "upload_act_single.cfm") 
      .attr("method", "post") 
      .attr("enctype", "multipart/form-data") 
      .attr("encoding", "multipart/form-data") 
      .attr("target", strName); 
     }); 

我想我必须有一些语法错误搞乱了的作品,但我是新够这没看出来。当我使用alert来调用objData变量时,它会在Safari中表示“未定义”。它的行为就像它甚至不运行CF脚本...提前感谢您的帮助。

回答

0

而不是使用about:blank,尝试使用body标签创建您自己的空HTML。我在Safari 4(windows)和Chrome中查看了源代码。关于:空白的源代码与IE或者其中包含HTML的Firefox不同。尝试提醒(objUploadBody),看看你是否也得到了它。

+0

谢谢,airmanx86。我决定放弃这个,并改用Valum的AjaxUpload插件。 – Ofeargall 2010-07-20 18:17:28

相关问题