Scroll to Element within CKEditor
CKEditor is the outstanding WYSIWYG editor we use on the Mozilla Developer Network. We have many custom plugins and we do everything we can to make writing easy for contributors. One trick I just picked up was skipping to an element within the editor by ID and setting the cursor focus within that element. Here's how!
The JavaScript
You'll start by scrolling the element into view within CKEditor:
var element = editor.document.getById('someHeading');
var range;
if(element) {
element.scrollIntoView();
// Thank you S/O
// http://stackoverflow.com/questions/16835365/set-cursor-to-specific-position-in-ckeditor
range = editor.createRange();
range.moveToPosition(element, CKEDITOR.POSITION_AFTER_START);
editor.getSelection().selectRanges([range]);
}
With the element in view, you'll attempt to insert the cursor at the beginning of the element using a Range.
Firefox will actually insert the cursor for you but Chrome wont, so the Range step is necessary.
My team mate Edna Piranha is not only an awesome hacker; she's also a fantastic philosopher! Communication and online interactions is a subject that has kept her mind busy for a long time, and it has also resulted in a bunch of interesting experimental projects...
CSS filter support recently landed within WebKit nightlies. CSS filters provide a method for modifying the rendering of a basic DOM element, image, or video. CSS filters allow for blurring, warping, and modifying the color intensity of elements. Let's have...
CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a language capable of creating deep, creative visuals. Add animation and you've got something really neat. Unfortunately each CSS cube tutorial I've read is a bit...
The way that album information displays is usually insanely boring. Music is supposed to be fun and moving, right? Luckily MooTools and jQuery allow us to communicate that creativity on the web.
The XHTML
A few structure DIVs and the album information.
The CSS
The CSS...
Instead of
you can simply use
Updated, thank you!
This will work for sure.