簡體   English   中英

如何在CKEditor 4中將焦點設置在輸入元素上?

[英]How to set focus on an input element in CKEditor 4?

對於鏈接對話框,我只向用戶顯示一個最小對話框:

截圖

config.js文件中的代碼:

CKEDITOR.on('dialogDefinition', function(ev) {
    // Take the dialog name and its definition from the event data.
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;

    // Check if the definition is from the dialog we are interested in (the 'link' dialog)
    if (dialogName == 'link') {
        // Get a reference to the 'Link Info' tab.
        var infoTab = dialogDefinition.getContents('info');
        // Remove unnecessary widgets from the 'Link Info' tab.
        infoTab.remove('linkType');
        infoTab.remove('protocol');
        infoTab.remove('browse');

        // Get a reference to the "Target" tab and set default to '_blank'
        var targetTab = dialogDefinition.getContents('target');
        var targetField = targetTab.get('linkTargetType');
        targetField['default'] = '_blank';

    // focus URL field
    // targetTab.focus(); // NOT working, function does not exist
    }
}

有人可以告訴我如何關注輸入字段嗎?

PS:我也嘗試使用dialogDefinition.onShow = function () { }失敗。

在對話框定義中覆蓋onFocus方法:

if (dialogName == 'link') {
    ....
    dialogDefinition.onFocus = function() {
        this.getContentElement( 'info', 'url' ).focus();
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM