5
<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]
4

2 回答 2

8

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

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

我想你现在已经解决了这个问题,但我希望它会对某人有所帮助。

于 2009-12-05T10:34:21.033 回答
3

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

<div style="position: absolute; left: -1000px; width: 100px">
于 2009-10-04T12:34:02.647 回答