【问题标题】:Weird iframe behavior in IE9IE9 中奇怪的 iframe 行为
【发布时间】:2013-03-25 18:03:55
【问题描述】:

在有人抱怨之前,我不使用iframes(但在尝试修复错误时,我发现问题与iframe 在IE9 中的一种奇怪行为有关,并且它是由其他人编码的) .

我有一个 JSON 在点击提交后被发送到 iframe:

    <a id="general_Submit.Label" class="formActionLink" href="javascript:submitAndSendEmail();"/>

    <form name="fileUploader" id="fileUploader" enctype="multipart/form-data" method="post" action="ajaxFileUploadAction.action" target="upload_target">
        <input type="file" name="upload" id="upload" size="40" onchange="dynFileUploader.uploadFile(this);" onkeyup="dynFileUploader.checkValidFile(this)" />
        <iframe name="upload_target" id="upload_target" src="" onload="javascript:dynFileUploader.uploadDone();"> </iframe>
    </form>

问题

该操作正在正确返回 JSON:

{"JSONClass":"com.lalala.process.email.util.FileContentHolder",
"contentType":"application/pdf","data":[],"fileLength":348364,
"fileName":"001a.<space>bla<space>refrigeration<space><space>-<space>aaa<space>- <space>Tenderer<space>Instructions.pdf",
"tempFileName":"C:\\Users\\humbleUser\\AppData\\Local\\Temp\\UPLOADED_7567343180347343279_001a.<space>bla<space>refrigeration<space><space>-<space>aaa<space>-<space>TendererInstructions.pdf"}

问题出在文件名中:在冷藏一词之后有两个空格。当我们通过使用target="upload_target" 将此 json 发送到 iframe 时,它​​会在没有这些空格的情况下到达 iframe。例如:

如果我们有文件:test1.pdf,在 IE 中,它会作为 test1.pdf 进入 iframe

为什么我们会有这种行为?当然它不会发生在 Firefox 中。

【问题讨论】:

    标签: json internet-explorer iframe whitespace


    【解决方案1】:

    我可以看到没有人从来没有遇到过它,我认为这是 IE 的另一种行为,它必须将连续的空格视为唯一一个。在搜索时,我注意到这是文件名的常见问题,正如我们在 link 中看到的那样。

    无论如何,在我看来,这个问题的答案是它是来自 IE 的错误。 我解决了我的错误(当用户试图上传一个文件名包含多个连续空格的文件时,它没有被正确保存,因为这些空格被减少到只有一个,所以我通过替换下划线的空格来修复它,它工作得很好!)

    【讨论】:

      猜你喜欢
      • 2012-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-28
      • 2018-09-04
      • 1970-01-01
      • 1970-01-01
      • 2012-11-09
      相关资源
      最近更新 更多