FCKeditor的JavaScript API第抛出"安全错误" code:" 1000 QUOT;当我尝试SetHTML() [英] FCKeditor JavaScript API throws "Security error" code: "1000" when I attempt SetHTML()

查看:186
本文介绍了FCKeditor的JavaScript API第抛出"安全错误" code:" 1000 QUOT;当我尝试SetHTML()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在它exatly 1 FCKeditor的窗口中打开一个网页后,我得到的实例:

  I = FCKeditorAPI.GetInstance(txtText)

这工作。我也可以的:

  i.GetHTML()#=> < D​​IV CLASS =......等等,正确的输出

但是,试图在

  i.SetHTML(< H1>&QUUX LT; / H1>中)

我得到:

  [异常...安全错误code:1000nsresult:0x805303e8(NS_ERROR_DOM _...等]

我有一种不确定的感觉,过去,我能与SetHTML()来改变FCKeditor的窗口内容,但我不能完全确定。怎么办?

在响应于该评论,我的HTML是

 <!DOCTYPE HTML PUBLIC -  // W3C // DTD XHTML 1.0 Strict标准// ENhttp://www.w3.org/TR/xhtml1/DTD/ XHTML1-strict.dtd>
< HTML的xmlns =htt​​p://www.w3.org/1999/xhtmlXML:LANG =CSLANG =CS>< HEAD>
< META HTTP-EQUIV =Content-Type的CONTENT =text / html的;字符集=窗口-1250/>
< META HTTP-EQUIV =内容语言CONTENT =CS/>
< META HTTP-EQUIV =过期CONTENT = - 1/>
< META HTTP-EQUIV =编译内容=无缓存/>
< META HTTP-EQUIV =缓存控制内容=私有/>
<标题>美孚|酒吧| WebMaker | FOO.CZ< /标题>
<风格类型=文/ CSS媒体=屏幕> / *<![CDATA [* / @进口网址(http://webmaker.ooo.cz/_design/style.css); / * ]]> * /< /风格>
<脚本类型=文/ JavaScript的SRC =htt​​p://webmaker.ooo.cz/common.js>< / SCRIPT>
< /头><身体GT;
< D​​IV ID =头>
        &所述;跨度>&下; A HREF =htt​​p://webmaker.ooo.cz/logout.aspx>注销&下; /强>&下; /跨度>
< / DIV>
    < D​​IV ID =主>        < D​​IV ID =内容>
            < D​​IV ID =tabmenu>            < / DIV><! - / tabmenu - >
            < D​​IF ID =tabcontent>
              <表格名称=_ CTL2的方法=邮报行动=detail.aspx文章= 14599?ID =_ CTL2>
<输入类型=隐藏的名字=__ EVENTTARGETID =__ EVENTTARGETVALUE =/>
<输入类型=隐藏的名字=__ EVENTARGUMENTID =__ EVENTARGUMENTVALUE =/>
<输入类型=隐藏的名字=__ VIEWSTATEID =__ VIEWSTATEVALUE =/ wEPDwULLTE2MTEzz0iZG9 ..... reallllly..looong ...〜应变...... 6qKb5or30J5DCLKTCaFR / xc8TPHb9A =/><脚本类型=文/ JavaScript的>
  <! -
      VAR theForm = document.forms ['_ CTL2'];
      如果(!theForm){
          theForm = document._ctl2;
      }
      功能__doPostBack(的eventTarget,eventArgument){
          如果(!theForm.onsubmit ||(theForm.onsubmit()!= FALSE)){
              theForm .__ EVENTTARGET.value =的eventTarget;
              theForm .__ EVENTARGUMENT.value = eventArgument;
              theForm.submit();
          }
      }
   // - >
< / SCRIPT><输入类型=隐藏的名字=__ EVENTVALIDATIONID =__ EVENTVALIDATIONVALUE =/ wEWEQ ... vsyXR4 =/>
    < D​​IV CLASS =数据>
    <&字段集GT;
<传奇>文字článku< /传说>< D​​IV><输入类型=隐藏ID =txtTextNAME =txtTextVALUE =FCK编辑窗口在这里的内容。 /><输入类型=隐藏ID =txtText ___配置值=HtmlEn codeOutput可以=真正的/>< IFRAME ID =txtText ___相框 src=\"http://webmaker.ooo.cz/_wysiwyg/editor/fckeditor.html?InstanceName=txtText&Toolbar=WebMaker\" WIDTH =100%HEIGHT =400像素FRAMEBORDER =无SCROLLING =NO>< / IFRAME>< / DIV>
<输入类型=按钮的onclick =GetWordsCount('txtText ___框架')VALUE =ZobrazitpočetSLOV včlánku/>
    < /字段集>    <! - 这里有一些更多的字段集和一个提交按钮。 - >                  < / DIV><! - 。数据 - >
              < /表及GT;
            < / DIV><! - tabcontent - >
< / DIV><! - /主 - >
< /身体GT;
< / HTML>


解决方案

的FCKeditor的 SetHTML 方法依赖于文件撰写调用替换编辑控件的内容。不幸的是文件撰写不从Firefox的Web控制台内工作。

这是一个已知的bug:使用便签窗口内的document.write带来了安全错误未定义Web控制台

我知道错误说暂存和错误信息是不同的,但它同样的问题。注此评论


  

这似乎是另一个bug在一个沙箱中运行Web控制台/暂存器。


您可能还记得能够做到这一点,在过去的原因是因为它的工作原理在Firebug,它在Chrome工作。与FCKeditor的控制时,您可能已经在过去使用的环境之一。

After opening a webpage with exatly one FCKeditor window in it, I get the instance:

i = FCKeditorAPI.GetInstance( "txtText" )

This works. I am also allowed:

i.GetHTML() #=> <div class=".... etc., correct output

But when trying

i.SetHTML( "<h1>Quux</h1>" )

I get:

[Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_... etc. ]

I have an uncertain feeling, that in past, I was able to change the FCKeditor window contents with SetHTML(), but I'm not completely sure. What to do?

In response to the comment, my HTML is

<!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&amp;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's SetHTML method relies on a document.write call to replace the content in the edit control. Unfortunately document.write does not work from within the Web Console on Firefox.

This is a known bug: Using document.write inside Scratchpad window brings up 'Security error undefined' in Web Console

I know that error says Scratchpad and the error message is different but it's the same problem. Note this comment from David Chan (Mozilla Security Researcher):

This appears to be another bug from running WebConsole / ScratchPad in a sandbox.

The reason you probably remember being able to do this in the past is because it works in FireBug, and it works in Chrome. You've probably used one of those environments in the past when working with a FCKeditor control.

这篇关于FCKeditor的JavaScript API第抛出&QUOT;安全错误&QUOT; code:&QUOT; 1000 QUOT;当我尝试SetHTML()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆