Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scroll to specific content in TinyMCE editor

I am using TinyMCE editor plugin with ASP.NET and MVC3.

I want to scroll to particular DIV content in html. How can i do that.

 var ed = tinymce.editors[0];
        var $marker = $(ed.getBody()).find('#Content_500');
        tinymce.activeEditor.selection.select($marker.get(0)).focus();

With this, the specific content is selected, but the cursor doe not scroll to the content.

ANy ideas..

like image 404
Marcus25 Avatar asked Sep 20 '25 11:09

Marcus25


1 Answers

This is possible.

To scroll in an tinymce editor or iframe you can use the following

$(tinymce.activeEditor.getBody()).animate({ scrollTop: 300 }, { duration: 'medium', easing: 'swing' });

To scroll to a specified element you may use

$(tinymce.activeEditor.getBody()).find('#content_500').get(0).scrollIntoView();
like image 160
Thariama Avatar answered Sep 23 '25 11:09

Thariama