Search code examples
iframeyuicontenteditable

contenteditable iframe editable height limit


I'm using the yui editor. I want to know if it possible to limit the editable height area.

ex: height:300px, so over 300px, the carret stop writting.

thanks


Solution

  • html:
    
    <textarea id="countMe" cols="30" rows="5"></textarea>
    <div class="theCount">Lines used: <span id="linesUsed">0</span><div>js:
    

    $(document).ready(function(){

    var lines = 10;
    var linesUsed = $('#linesUsed');
    
    $('#countMe').keydown(function(e) {
    
        newLines = $(this).val().split("\n").length;
        linesUsed.text(newLines);
    
        if(e.keyCode == 13 && newLines >= lines) {
            linesUsed.css('color', 'red');
            return false;
        }
        else {
            linesUsed.css('color', '');
        }
    });
    

    });

    You can do some code on your editor panel when user enter characters & calculate length and return false if limit exceeds.