FCKeditor JavaScript API抛出“安全错误”;代码:“1000”;当我尝试SetHTML()
FCKeditor JavaScript API throws "Security error" code: "1000" when I attempt SetHTML()
打开一个只有一个FCKeditor窗口的网页后,我得到实例:
i = FCKeditorAPI.GetInstance( "txtText" )
这工作。我也允许:
i.GetHTML() #=> <div class=".... etc., correct output
但当尝试
时i.SetHTML( "<h1>Quux</h1>" )
我:
[Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_... etc. ]
我有一种不确定的感觉,在过去,我能够用SetHTML()改变FCKeditor窗口内容,但我不完全确定。该怎么办?
回复评论,我的HTML是
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
<meta http-equiv="Content-language" content="cs" />
<meta http-equiv="expires" content="-1" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="private" />
<title>Foo | Bar | WebMaker | FOO.CZ</title>
<style type="text/css" media="screen">/*<![CDATA[*/@import url(http://webmaker.ooo.cz/_design/style.css);/*]]>*/</style>
<script type="text/javascript" src="http://webmaker.ooo.cz/common.js"></script>
</head>
<body>
<div id="header">
<span><a href="http://webmaker.ooo.cz/logout.aspx">Logout</strong></span>
</div>
<div id="main">
<div id="content">
<div id="tabmenu">
</div><!-- /tabmenu -->
<dif id="tabcontent">
<form name="_ctl2" method="post" action="detail.aspx?article=14599" id="_ctl2">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTEzz0iZG9.....reallllly..looong...strin......6qKb5or30J5DCLKTCaFR/xc8TPHb9A=" />
<script type="text/javascript">
<!--
var theForm = document.forms['_ctl2'];
if (!theForm) {
theForm = document._ctl2;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWEQ...vsyXR4=" />
<div class="data">
<fieldset>
<legend>Text článku</legend>
<div><input type="hidden" id="txtText" name="txtText" value="FCK editor window contents here." /><input type="hidden" id="txtText___Config" value="HtmlEncodeOutput=true" /><iframe id="txtText___Frame" src="http://webmaker.ooo.cz/_wysiwyg/editor/fckeditor.html?InstanceName=txtText&Toolbar=WebMaker" width="100%" height="400px" frameborder="no" scrolling="no"></iframe></div>
<input type="button" onclick="GetWordsCount('txtText___Frame')" value="Zobrazit počet slov v článku" />
</fieldset>
<!-- There are some more fieldsets here and a submit button. -->
</div><!-- .data -->
</form>
</div><!-- tabcontent -->
</div><!-- /main -->
</body>
</html>
FCKeditor的SetHTML
方法依赖于document.write
调用来替换编辑控件中的内容。不幸的是,document.write
不能在Firefox的Web控制台内工作。
这是一个已知的bug: Using document。在"便签本"窗口中写入时会在Web控制台出现"安全错误未定义"
我知道错误说Scratchpad和错误信息是不同的,但它是相同的问题。请注意David Chan (Mozilla安全研究员)的评论:
这似乎是在沙盒中运行WebConsole/ScratchPad的另一个错误。
你可能记得过去能够这样做的原因是因为它在FireBug中有效,在Chrome中也有效。您可能在过去使用FCKeditor控件时使用过这些环境之一。
非常确定这是一些跨域问题,您可能认为您在同一域上运行,但实际上不是。我将不得不检查实际的页面上运行的真正能够帮助你,但尝试加载所有相关的fckeditor文件使用相对文件路径(可选从根)和从不包括实际的域,这将防止很多麻烦一般(例如可能发生的事情是你在example.com上,但从www.example.com或类似的问题加载文件)。
奇怪的是,你不应该能够读取文件,然后,但触发的错误是关于非特权的操作,几乎总是跨域问题(或一些非常棘手的跨脚本上下文问题,但这些大多只相关,如果你开发的插件)。
如果你的javascript来自"http://webmaker.ooo.cz/…",那么这是可能的,你得到一个域名问题,如果你正在浏览的网站不同的子域比javascript被拉出。我不确定解决办法,我也不确定这就是问题所在。只是一种可能性。我建议试着把你正在使用的javascript与html页面只是为了确保代码本身实际工作。
- Javascript图形可视化工具包,具有高性能(500-1000个节点)
- 创建一个javascript数组(N),该数组由连续的较小整数组成,其和为1000
- 包括Quill setHTML中的样式
- 是什么让新的Date() / 1000成为一个有效的javascript
- D3/Raphael js 以慢帧率绘制 1000+ 动画圆圈
- 如何从包含1000个项目的数组中随机选择一个项目
- QWebView.setHtml没有't加载CSS文件
- JavaScript 数组中元素的最大数量.浏览器不允许超过 1000 个元素
- jquery选择器在1000+元素与450Mhz机器时变慢
- Blueimp 上传插件使用 1000 字节作为单个 kb 而不是 1024
- 1000 mp3 歌曲使 HTML5 音频标签滞后
- 使用 $.ajax 从服务器加载 1000+ 条记录时出错
- 仅当屏幕上显示 <1000 像素时调用 JS 函数
- Firefox 在这个简单的枚举上抛出安全错误 1000
- 如何格式化干净的数字,使 1000 显示为 1.000,00
- 如何有效地加载1000 +谷歌地球标记
- 使用指令在 1000 条记录上的两个表之间进行角度拖放
- Node Js :是否可以从节点 js 服务器向某些 API 发出 1000 http get 请求
- 有没有理由 math.round *1000 /1000 没有意义
- FCKeditor JavaScript API抛出“安全错误”;代码:“1000”;当我尝试SetHTML()