【问题标题】:How to hide wmd editor initially?最初如何隐藏 wmd 编辑器?
【发布时间】:2009-10-04 12:30:18
【问题描述】:
<div style="display:none;">
    <div id="wmd-editor" class="wmd-panel">
        <div id="wmd-button-bar"></div>
        <textarea id="wmd-input"></textarea>
    </div>
    <div id="wmd-preview" class="wmd-panel"></div>
    <div id="wmd-output" class="wmd-panel"></div>   
</div>  

看,我正在关注 derobins-wmd 的 wmd-test.html,除了把那些东西放在一个隐藏的 div 里。

uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLTextAreaElement.selectionStart]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost/derobins-wmd-980f687/wmd.js :: anonymous :: line 490" data: no]
uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLTextAreaElement.selectionStart]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost/derobins-wmd-980f687/wmd.js :: anonymous :: line 490" data: no]

【问题讨论】:

    标签: javascript wmd


    【解决方案1】:

    除了隐藏带有 textarea 的整个面板之外,您还需要确保 textarea 本身具有display:none,然后问题就会消失。否则 wmd 将不会检测到 textarea 没有显示,并会尝试对其进行计算,你会得到你所说的异常。

    简单地将元素移出屏幕是不可能的,或者至少对于某些布局来说非常麻烦。此外,屏幕阅读器仍会检测到这些元素,并且可访问性会受到影响。

    我猜你现在已经解决了这个问题,但我希望它能帮助别人。

    【讨论】:

    • 谢谢,我也遇到了同样的问题,google了一下,找到了。将 display:none 添加到 textarea 以及包装 div 工作。
    • 值得注意的是,如果您使用的是 jquery 选项卡(这就是我们发现此问题的方式),您只需添加 css .ui-tabs-hide textarea { display: none; } 就会产生类似的效果。
    【解决方案2】:

    如果插件不喜欢没有高度/宽度的元素,您可以使用偏左技术。

    <div style="position: absolute; left: -1000px; width: 100px">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-21
      • 2011-05-05
      • 2011-06-17
      • 2010-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多