Marcus25
Marcus25

Reputation: 883

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..

Upvotes: 4

Views: 8701

Answers (2)

laurent
laurent

Reputation: 90756

With TinyMCE 5+, this would work:

tinymce.activeEditor.getWin().scrollTo(0, 0); // Scroll to top

Upvotes: 2

Thariama
Thariama

Reputation: 50832

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();

Upvotes: 10

Related Questions