【问题标题】:Freemarker rendering differently on IE8Freemarker 在 IE8 上的渲染方式不同
【发布时间】:2012-09-06 15:32:30
【问题描述】:

我们有一个用于记录行的模板

<input type="${inputType}" name="${variableName}.code" id="${variable}.${vnum}.${answer.code}" class="checkbox" value="${answer.code}"
             [#nested/] [#if (answer.textLength > 0) && scripting]onchange="showOtherBox( this, '${variable}.[#if descriptionHack]${variableNumber}[#else]${vnum}[/#if].${answer.code}.description' )"[/#if]
             [#if showValues && (existing == answer.code)]checked="checked"[/#if]/>

在 IE8 上它呈现为这样

<span class="field">
<INPUT id=responses.8.L class=checkbox value=L type=checkbox name="responses['8'].answers['L'].code"> 
<LABEL for=responses.8.L>Award(s) for special accomplishment or performance related to activity participation (please list)</LABEL> 
<TEXTAREA id=responses.8.L.description class=" visible" rows=4 cols=60 name="responses['8'].answers['L'].description"></TEXTAREA> 
</span>

在我们尝试过的所有其他浏览器上,它都呈现为这样

<span class="field">
<input type="checkbox" name="responses['8'].answers['L'].code" id="responses.8.L" class="checkbox" value="L" onchange="showOtherBox( this, 'responses.8.L.description' )">
<label for="responses.8.L">Award(s) for special accomplishment or performance related to activity participation (please list)</label>
<textarea rows="4" cols="60" name="responses['8'].answers['L'].description" id="responses.8.L.description" class="visible" classname="visible"></textarea>
</span>

不同之处在于 FTL 脚本中的 if 语句

[#if (answer.textLength > 0) && scripting]

适用于除 IE 之外的所有内容。在 IE8 中,由于某种原因它为 false,因此它不会将 OnChange javascript 事件放在输入标记上。有没有人见过这样的事情?我们正在使用 Freemarker 2.3.9

更新,如果我打开 IE8 的兼容模式,它会起作用。但不完全是。当我这样做时,onchange 事件不会触发,直到复选框失去焦点。这与其他一切都非常不同。有没有一种快速的方法来解决这个问题而没有太多麻烦?我想我可以放一些东西,如果 ie8,插入 onclick 而不是 onchange。这可能有效,但我需要客户的授权才能修复它。

【问题讨论】:

    标签: freemarker


    【解决方案1】:

    由于 FreeMarker 只在服务器上运行,它不受浏览器的直接影响。您应该在[#if] 之前放置类似&lt;!-- answer.textLength = ${answer.textLength}, scripting = ${scripting?string} --&gt;) 的内容,这样您就可以看到条件失败的确切原因,然后找出有问题的变量的值来自哪里,因为通常不是FreeMarker 设置它。 (准系统 FreeMarker 甚至无法检测浏览器类型。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-10
      • 1970-01-01
      • 2014-08-28
      • 2015-09-17
      • 2016-12-26
      相关资源
      最近更新 更多