English 中文(简体)
在新的java制文字要素内保留java语
原标题:Keep javascript within new javascript element

我正在开发一个网页,但我对一些 j印法感到有些麻烦。

我将Nicedit作为文本领域WYSIWYG。

<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>         

这与该页的缺省案文相干。 问题在于,我还有这个小篇章来补充更多的文字:

function addchapter()
  {
  if (num_chapter < 10)
    {
    var num=num_chapter+1;
    document.getElementById( chapters ).innerHTML += "<h3>Chapter " + num + "</h3> Title: <input type= text  name= titlechapter_" + num + " ><br>Content:<textarea  name= chapter_" + num + " ></textarea>";
    }
  else if (num_chapter == 10)
    {
    document.getElementById( chapters ).innerHTML += "<br />Maximum is 10 chapters.";
    }
  num_chapter += 1;
  }

因此,当我通过javascript增加一个文字时,它没有适当的风格;它没有执行尼斯迪特。 情况是,案文是所有标准,因此两种情况下的法典之间没有任何区别。 我不了解太多的javascript,但我认为,问题可能是尼斯迪特法在页数上运行欧安会,而那是这样。 Any concept of how to make it industry when the pageloads (<= have made) and when the add Chapter function is conducted?

相关的超文本轨道是:

 <div id="chapters">
 </div>
 <button type="button" onclick="addchapter()"> Add chapter </button>

见第1章,你可以看到奇迹:,>(中链条)。

非常感谢大家。

EDIT 1, Error console output: When the page loads it throws this:

"GET http://js.nicedit.com/nicEditIcons-latest.gif 
bkClass.extend.getStylenicEdit-latest.js:8
bkClass.extend.constructnicEdit-latest.js:38
AnicEdit-latest.js:8
bkClass.extend.addInstancenicEdit-latest.js:37
bkClass.extend.panelInstancenicEdit-latest.js:37
nicEditors.allTextAreasnicEdit-latest.js:37
bkLib.domLoaded"

在我增加一个新篇章时:

"Uncaught TypeError: Object #<bkClass> has no method  removeInstance 
bkClass.extend.checkReplacenicEdit-latest.js:37
bkClass.extend.panelInstancenicEdit-latest.js:37
nicEditors.allTextAreasnicEdit-latest.js:37
(anonymous function)/file/new/:112
onclick"
最佳回答

你必须给你在网页上添加的文字领域指定一个独特的身份证。 之后可打电话给编辑。

nicEditors.findEditor(editorID);

或您可再次打电话nicEditors.allTextAreas()。 但是,我不敢肯定,这是否会从已经存在的编辑中删除现有内容。

资料来源:

问题回答

您可以添加手法的试样子。

jQuery( .js-control-des ).each(function () {
            var index = jQuery(this).attr( lang );
            var editor = jQuery(this).find( textarea );
            var editor_id = editor.attr( id );
            var editor_loaded = editor.attr( rel );
            if (editor_loaded == undefined || editor_loaded != null || editor_loaded == 0) {
                var editor_new_width = parseFloat(editor.css( min-width )) + 7 +  px ;
                editor.css({
                    width: editor_new_width,
                     max-width : editor_new_width,
                     min-width : editor_new_width
                });
                try {
                    new nicEditor({maxHeight: 300}).panelInstance(editor_id);
                    jQuery(this).attr( rel ,  editor-loaded );
                    jQuery(this).find( .nicEdit-main ).attr( data-index , index).keyup(function (e) {
                        if (vnLineUcp.editorKeyUp(jQuery(this)) == false) {
                            return false;
                        }
                    });
                } catch (e) {
                }
            }
        });




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.