在ckeditor文档中获取锚定
我正在使用ckeditor,我们构建了一个自定义插件来定义指向页面上锚的链接。现在,当我尝试获取页面上的所有锚时,没有返回任何内容 我的HTML如下所示:在ckeditor文档中获取锚定,ckeditor,anchor,Ckeditor,Anchor,我正在使用ckeditor,我们构建了一个自定义插件来定义指向页面上锚的链接。现在,当我尝试获取页面上的所有锚时,没有返回任何内容 我的HTML如下所示: <p> <a name="anchor-anchor"></a></p> 但是当我尝试像这样获取文档中的所有锚定时: editor.document.getElementsByTag(“a”) 一无所获。但是当我放置一个普通的锚时,上面的代码会发现。 我做错什么了吗 问候 这直接
<p>
<a name="anchor-anchor"></a></p>
但是当我尝试像这样获取文档中的所有锚定时:editor.document.getElementsByTag(“a”)
一无所获。但是当我放置一个普通的锚时,上面的代码会发现。
我做错什么了吗
问候 这直接来自链接对话框:
// Find out whether we have any anchors in the editor.
// Get all IMG elements in CK document.
var elements = editor.document.getElementsByTag( 'img' ),
realAnchors = new CKEDITOR.dom.nodeList( editor.document.$.anchors ),
anchors = retval.anchors = [];
for ( var i = 0; i < elements.count() ; i++ )
{
var item = elements.getItem( i );
if ( item.data( 'cke-realelement' ) && item.data( 'cke-real-element-type' ) == 'anchor' )
anchors.push( editor.restoreRealElement( item ) );
}
for ( i = 0 ; i < realAnchors.count() ; i++ )
anchors.push( realAnchors.getItem( i ) );
for ( i = 0 ; i < anchors.length ; i++ )
{
item = anchors[ i ];
anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) };
}
//找出编辑器中是否有锚。
//获取CK文档中的所有IMG元素。
var elements=editor.document.getElementsByTag('img'),
realAnchors=new CKEDITOR.dom.nodeList(editor.document.$.anchors),
anchors=retval.anchors=[];
对于(var i=0;i
这是直接从链接对话框:
// Find out whether we have any anchors in the editor.
// Get all IMG elements in CK document.
var elements = editor.document.getElementsByTag( 'img' ),
realAnchors = new CKEDITOR.dom.nodeList( editor.document.$.anchors ),
anchors = retval.anchors = [];
for ( var i = 0; i < elements.count() ; i++ )
{
var item = elements.getItem( i );
if ( item.data( 'cke-realelement' ) && item.data( 'cke-real-element-type' ) == 'anchor' )
anchors.push( editor.restoreRealElement( item ) );
}
for ( i = 0 ; i < realAnchors.count() ; i++ )
anchors.push( realAnchors.getItem( i ) );
for ( i = 0 ; i < anchors.length ; i++ )
{
item = anchors[ i ];
anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) };
}
//找出编辑器中是否有锚。
//获取CK文档中的所有IMG元素。
var elements=editor.document.getElementsByTag('img'),
realAnchors=new CKEDITOR.dom.nodeList(editor.document.$.anchors),
anchors=retval.anchors=[];
对于(var i=0;i